(* Content-type: application/vnd.wolfram.mathematica *)

(*** Wolfram Notebook File ***)
(* http://www.wolfram.com/nb *)

(* CreatedBy='Mathematica 12.0' *)

(*CacheID: 234*)
(* Internal cache information:
NotebookFileLineBreakTest
NotebookFileLineBreakTest
NotebookDataPosition[       158,          7]
NotebookDataLength[    628057,      13673]
NotebookOptionsPosition[    615094,      13442]
NotebookOutlinePosition[    615490,      13458]
CellTagsIndexPosition[    615447,      13455]
WindowFrame->Normal*)

(* Beginning of Notebook Content *)
Notebook[{
Cell[BoxData[
 RowBox[{
  RowBox[{"(*", 
   RowBox[{"--", 
    RowBox[{"--", 
     RowBox[{"--", 
      RowBox[{"--", 
       RowBox[{"--", 
        RowBox[{"--", 
         RowBox[{"--", 
          RowBox[{"--", 
           RowBox[{"--", 
            RowBox[{"--", 
             RowBox[{"--", 
              RowBox[{"--", 
               RowBox[{"--", 
                RowBox[{"--", 
                 RowBox[{"--", 
                  RowBox[{"--", 
                   RowBox[{"--", 
                    RowBox[{"--", "-"}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}], 
   "*)"}], "\[IndentingNewLine]", 
  RowBox[{"(*", 
   RowBox[{"--", 
    RowBox[{"--", 
     RowBox[{"--", 
      RowBox[{"--", 
       RowBox[{"--", 
        RowBox[{"--", 
         RowBox[{"--", 
          RowBox[{"--", 
           RowBox[{"--", 
            RowBox[{"--", 
             RowBox[{"--", 
              RowBox[{"--", 
               RowBox[{"--", 
                RowBox[{"--", 
                 RowBox[{"--", 
                  RowBox[{"--", 
                   RowBox[{"--", 
                    RowBox[{"--", "-"}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}], 
   "*)"}], "\[IndentingNewLine]", 
  RowBox[{"(*", 
   RowBox[{"--", 
    RowBox[{"--", 
     RowBox[{"--", 
      RowBox[{"--", 
       RowBox[{"--", 
        RowBox[{"--", 
         RowBox[{"--", 
          RowBox[{"--", 
           RowBox[{"--", 
            RowBox[{"--", 
             RowBox[{"--", 
              RowBox[{"--", 
               RowBox[{"--", 
                RowBox[{"--", 
                 RowBox[{"--", 
                  RowBox[{"--", 
                   RowBox[{"--", 
                    RowBox[{"--", "-"}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}], 
   "*)"}], "\[IndentingNewLine]", 
  RowBox[{"(*", 
   RowBox[{"Specify", " ", "helpful", " ", "Methods"}], "*)"}]}]], "Input",
 CellChangeTimes->{{3.773063588863*^9, 3.773063606530117*^9}},
 CellLabel->"In[1]:=",ExpressionUUID->"f343e170-cce4-48b2-ab42-d6f7c113e011"],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{
   RowBox[{
    RowBox[{"SolveModel", " ", "-", " ", 
     RowBox[{
     "Module", " ", "that", " ", "saves", " ", "the", " ", "Main", " ", 
      "Models", " ", "of", " ", "the", " ", 
      RowBox[{"Paper", ".", " ", "Expand"}], " ", "to", " ", 
      RowBox[{"view", ".", " ", "N"}], " ", "agents"}]}], ";", " ", 
    RowBox[{
    "Take", " ", "population", " ", "as", " ", "given", " ", "and", " ", 
     "infer", " ", "costs"}]}], ",", " ", 
   RowBox[{
    RowBox[{"k", " ", "on", " ", "saddle", " ", 
     RowBox[{"path", ".", " ", "Pie"}], " ", "Changes"}], ";", " ", 
    RowBox[{
     RowBox[{"0", "<=", "\[Omega]", "<=", 
      RowBox[{
       RowBox[{"1", " ", "--"}], " ", "if", " ", "\[Omega]"}]}], "=", 
     RowBox[{
      RowBox[{
      "1", " ", "then", " ", "perfect", " ", "altruism", " ", "if", " ", 
       "\[Omega]"}], "=", 
      RowBox[{
      "0", " ", "then", " ", "Blanchard", " ", "type", " ", "selfishness", 
       " ", "mechanism", " ", "in", " ", "play"}]}]}], ";", " ", 
    RowBox[{
     RowBox[{
     "evaluatePercentiles", " ", "is", " ", "a", " ", "variable", " ", "that",
       " ", "is", " ", "zero", " ", "by", " ", 
      RowBox[{"default", ".", " ", "If"}], " ", "set", " ", "to", " ", "1", 
      " ", "it", " ", "provides", " ", "the", " ", "capital", " ", "and", " ",
       "population", " ", "share", " ", "of", " ", "specified", " ", 
      "percentiles"}], " ", "-", " ", 
     RowBox[{
     "this", " ", "slows", " ", "down", " ", "the", " ", "code", " ", 
      "significantly", " ", "and", " ", "should", " ", "be", " ", "avoided", 
      " ", "unless", " ", "these", " ", "are", " ", "needed"}]}]}]}], 
  "*)"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.},
 CellChangeTimes->{{3.5450253019140635`*^9, 3.545025304915063*^9}, {
   3.5450324742890635`*^9, 3.5450324819140635`*^9}, {3.724479346029998*^9, 
   3.7244794610184035`*^9}, {3.7244795438463507`*^9, 3.724479554254569*^9}, {
   3.7260565353620577`*^9, 3.7260565430614977`*^9}, 3.7260578532684374`*^9, 
   3.726579461512018*^9, {3.726579559728636*^9, 3.726579586301156*^9}, {
   3.7265804157025948`*^9, 3.726580472134823*^9}, {3.726675052388584*^9, 
   3.7266750541206837`*^9}, {3.726736336745963*^9, 3.72673634385637*^9}, {
   3.7267458479639735`*^9, 3.7267458612117314`*^9}, {3.7270949226440563`*^9, 
   3.7270949246821723`*^9}, 3.727096924615328*^9, 3.7271009968402452`*^9, {
   3.7271015671358647`*^9, 3.7271015677228985`*^9}, {3.7610437803591704`*^9, 
   3.7610437849279823`*^9}, {3.7619207454984493`*^9, 3.7619207476240177`*^9}, 
   3.7730639713097205`*^9, {3.776491683018301*^9, 3.7764917078746634`*^9}, {
   3.8515995582518587`*^9, 3.8515995628012094`*^9}, {3.851768684051326*^9, 
   3.8517686869411545`*^9}, {3.8520219625179977`*^9, 
   3.8520219654061565`*^9}, {3.8523736907830973`*^9, 3.852373695966022*^9}, {
   3.8945986752469788`*^9, 3.8945987151205263`*^9}, {3.9028079631192408`*^9, 
   3.90280801126972*^9}, {3.9029230954539957`*^9, 3.902923161658745*^9}, {
   3.9030681390406218`*^9, 3.90306815778736*^9}, {3.903068737263729*^9, 
   3.903068746954382*^9}},
 CellLabel->"In[7]:=",ExpressionUUID->"471ccfe1-307a-4ca5-8202-83acdbfd43a5"],

Cell[BoxData[
 RowBox[{
  RowBox[{
   RowBox[{"SolveModel", "[", 
    RowBox[{"parameterVector_", ",", 
     RowBox[{"evaluatePercentiles_", ":", "0"}]}], "]"}], ":=", 
   "\[IndentingNewLine]", 
   RowBox[{"Module", "[", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{
       RowBox[{"pVectorAll", "=", "parameterVector"}], ",", "pVector", ",", 
       "\[IndentingNewLine]", "\[Alpha]", ",", "\[Beta]A", ",", "\[Beta]B", 
       ",", "Pie", ",", "time", ",", "\[Xi]", ",", "\[Nu]", ",", 
       "\[IndentingNewLine]", "\[IndentingNewLine]", "wtilde", ",", "r", ",", 
       "Cetilde", ",", "citilde", ",", "gDee", ",", "eN", ",", "kiitilde", 
       ",", "Dee", ",", "afunc", ",", "ass", ",", "Deefuncx", ",", 
       "\[IndentingNewLine]", "\[IndentingNewLine]", "eqs", ",", "eqs1", ",", 
       "eqs2", ",", "eqs3", ",", "eqs4", ",", "eqs5", ",", 
       "\[IndentingNewLine]", "\[IndentingNewLine]", "eq", ",", "eq1", ",", 
       "eq2", ",", "eq3", ",", "eq4", ",", "eq5", ",", "\[IndentingNewLine]", 
       "\[IndentingNewLine]", "varRelcB0", ",", "answerAllNi", ",", 
       "answerktilde", ",", "answerAllci", ",", "answerAllKi", ",", 
       "answerAllsi", ",", "answerW", ",", "points", ",", "answerAllYi", ",", 
       "answerY", ",", "answera", ",", "relbeta", ",", "eNdata", ",", "greN", 
       ",", "answerD", ",", "answersavingsrate", ",", "answerK", ",", 
       "answery", ",", "Piess", ",", "Piefunc", ",", "relonealphabeta", ",", 
       "\[IndentingNewLine]", "\[IndentingNewLine]", "a", ",", " ", 
       "\[Delta]", ",", "N0", ",", "grDee", ",", "gNss", ",", "geN", ",", 
       "ktildess", ",", "ansSS", ",", "answerTemp", ",", "answerkitilde", ",",
        " ", "answerctilde", ",", "  ", "answerN", ",", "answerp", ",", 
       "answerR", ",", "answerCtildeAg", ",", "vars", ",", "answer", ",", " ",
        "\[Beta]vec", ",", "propNvec", ",", "sorted\[Beta]Location", ",", 
       "nTypes", ",", " ", "acc", ",", "temp", ",", "temp2", ",", "temp3", 
       ",", "tempNp", ",", "helper", ",", "helper2", ",", "helper3", ",", 
       "ci", ",", "Kii", ",", "Nii", ",", "sii", ",", "cij", ",", "Kij", ",", 
       "Nij", ",", "pct", ",", "answerCQuantiles", ",", "answerKQuantiles", 
       ",", "answerNQuantiles", ",", "indexpct", ",", "answerKii", ",", 
       "answerKi", ",", "answerSharesSelectedYears", ",", 
       "answerSocietalBeta", ",", "inityear", ",", "currentyear", ",", 
       "cyperiod", ",", "initPoint", ",", "\[Omega]", ",", "answerFert", ",", 
       "answerwNrK"}], "}"}], ",", "\[IndentingNewLine]", 
     "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"pVector", "=", 
       RowBox[{"pVectorAll", "[", 
        RowBox[{"[", 
         RowBox[{"All", ",", "2"}], "]"}], "]"}]}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{"inityear", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "1", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", 
       RowBox[{
        RowBox[{"initial", " ", "year"}], " ", "-", " ", 
        RowBox[{"i", ".", "e", ".", " ", "1300"}]}], "*)"}], 
      "\[IndentingNewLine]", 
      RowBox[{"currentyear", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "2", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", 
       RowBox[{
        RowBox[{"final", " ", "year"}], " ", "-", " ", 
        RowBox[{"i", ".", "e", ".", " ", "2000"}]}], "*)"}], 
      "\[IndentingNewLine]", 
      RowBox[{"cyperiod", "=", 
       FractionBox[
        RowBox[{"currentyear", "-", "inityear"}], "25"]}], ";", " ", 
      RowBox[{"(*", 
       RowBox[{"Number", " ", "of", " ", "generations"}], "*)"}], 
      "\[IndentingNewLine]", 
      RowBox[{"\[Delta]", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "3", "]"}], "]"}]}], ";", "      ", 
      RowBox[{"(*", 
       RowBox[{"depreciation", " ", "rate"}], "*)"}], "\[IndentingNewLine]", 
      RowBox[{"eNdata", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "4", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", "Population", "*)"}], "\[IndentingNewLine]", 
      RowBox[{"greN", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "5", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", 
       RowBox[{
       "Long", " ", "run", " ", "population", " ", "growth", " ", "rate"}], 
       "*)"}], "\[IndentingNewLine]", 
      RowBox[{"N0", "=", 
       RowBox[{
        RowBox[{"pVector", "[", 
         RowBox[{"[", "4", "]"}], "]"}], "[", 
        RowBox[{"[", "2", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", 
       RowBox[{"Population", " ", "in", " ", "period", " ", "0"}], "*)"}], 
      "\[IndentingNewLine]", 
      RowBox[{"Dee", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "6", "]"}], "]"}]}], ";", "  ", 
      RowBox[{"(*", 
       RowBox[{"Level", " ", "of", " ", "TFP"}], "*)"}], 
      "\[IndentingNewLine]", 
      RowBox[{"grDee", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "7", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", 
       RowBox[{
       "Long", " ", "run", " ", "growth", " ", "rate", " ", "of", " ", 
        "TFP"}], "*)"}], "\[IndentingNewLine]", 
      RowBox[{"\[Nu]", " ", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "8", "]"}], "]"}]}], ";", "   ", 
      RowBox[{"(*", 
       RowBox[{
       "Capital", " ", "Share", " ", "in", " ", "Production", " ", 
        "Function"}], "*)"}], "\[IndentingNewLine]", 
      RowBox[{"\[Alpha]", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "9", "]"}], "]"}]}], ";", "     ", 
      RowBox[{"(*", 
       RowBox[{"Preference", " ", "weight", " ", "on", " ", "consumption"}], 
       "*)"}], "\[IndentingNewLine]", 
      RowBox[{"Pie", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "10", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", 
       RowBox[{
       "Probability", " ", "of", " ", "death", " ", "of", " ", "adults"}], 
       "*)"}], "\[IndentingNewLine]", 
      RowBox[{"Piess", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "11", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", 
       RowBox[{
        RowBox[{
        "Probability", " ", "of", " ", "death", " ", "of", " ", "adults"}], 
        ",", " ", 
        RowBox[{"long", " ", "run"}]}], "*)"}], "\[IndentingNewLine]", 
      RowBox[{"\[Omega]", " ", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "12", "]"}], "]"}]}], ";", "    ", 
      RowBox[{"(*", 
       RowBox[{"Altruism", " ", "parameter"}], "*)"}], "\[IndentingNewLine]", 
      RowBox[{"time", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "13", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", " ", 
       RowBox[{"The", " ", "time", " ", "periods", " ", "under", " ", 
        RowBox[{"consideration", "."}]}], "*)"}], "\[IndentingNewLine]", 
      RowBox[{"\[Beta]vec", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "14", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", 
       RowBox[{"Reads", " ", "in", " ", "the", " ", "betas"}], "*)"}], 
      "\[IndentingNewLine]", 
      RowBox[{"propNvec", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "15", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", 
       RowBox[{
       "Reads", " ", "in", " ", "the", " ", "proportion", " ", "of", " ", 
        "variables", " ", "in", " ", "each", " ", "beta", " ", "category"}], 
       "*)"}], "\[IndentingNewLine]", 
      RowBox[{
       SubscriptBox["ktilde", 
        RowBox[{"-", "1"}]], "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "16", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", 
       RowBox[{
        RowBox[{
        "Reads", " ", "in", " ", "value", " ", "for", " ", "capital", " ", 
         "in", " ", "period"}], " ", "-", "1"}], "*)"}], 
      "\[IndentingNewLine]", 
      RowBox[{"acc", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "17", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", 
       RowBox[{"Accuracy", "/", "precision"}], "*)"}], "\[IndentingNewLine]", 
      RowBox[{"pct", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "18", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", 
       RowBox[{"Number", " ", "of", " ", "percentiles"}], "*)"}], 
      "\[IndentingNewLine]", 
      RowBox[{"If", "[", 
       RowBox[{
        RowBox[{
         RowBox[{"Length", "[", "pVector", "]"}], "\[Equal]", "19"}], ",", 
        "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"initPoint", "=", 
          RowBox[{"pVector", "[", 
           RowBox[{"[", "19", "]"}], "]"}]}], ";"}]}], " ", 
       RowBox[{"(*", 
        RowBox[{
        "Initial", " ", "Guess", " ", "to", " ", "solution", " ", "if", " ", 
         "given"}], "*)"}], "\[IndentingNewLine]", "]"}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"Piefunc", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"Piefunc", "[", "t", "]"}], "=", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"t", "\[LessEqual]", 
           RowBox[{
            RowBox[{"Length", "[", "Pie", "]"}], "-", "2"}]}], ",", 
          RowBox[{"Pie", "[", 
           RowBox[{"[", 
            RowBox[{"t", "+", "2"}], "]"}], "]"}], ",", "Piess"}], "]"}]}]}], 
      ";", " ", 
      RowBox[{"(*", 
       RowBox[{"Survivial", " ", "Probability", " ", "function"}], "*)"}], 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"sorted\[Beta]Location", "=", 
       RowBox[{"Reverse", "[", 
        RowBox[{"Ordering", "[", "\[Beta]vec", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", 
       RowBox[{
       "Returns", " ", "the", " ", "location", " ", "of", " ", "the", " ", 
        "sorted", " ", "betas", " ", "from", " ", "largest", " ", "to", " ", 
        "smallest", " ", "in", " ", "pVector\[Beta]"}], "*)"}], 
      "\[IndentingNewLine]", 
      RowBox[{"nTypes", "=", 
       RowBox[{"Length", "[", "\[Beta]vec", "]"}]}], ";", "  ", 
      RowBox[{"(*", 
       RowBox[{"Number", " ", "of", " ", "different", " ", "types"}], "*)"}], 
      "\[IndentingNewLine]", 
      RowBox[{"For", "[", 
       RowBox[{
        RowBox[{"i", "=", "1"}], ",", 
        RowBox[{"i", "\[LessEqual]", "nTypes"}], ",", 
        RowBox[{"i", "++"}], ",", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"j", "=", 
          RowBox[{"sorted\[Beta]Location", "[", 
           RowBox[{"[", "i", "]"}], "]"}]}], ";", 
         RowBox[{"(*", 
          RowBox[{
          "Find", " ", "the", " ", "location", " ", "of", " ", "the", " ", 
           "sorted", " ", "beta"}], "*)"}], "\[IndentingNewLine]", 
         RowBox[{
          SubscriptBox["\[Beta]", "i"], "=", 
          RowBox[{"\[Beta]vec", "[", 
           RowBox[{"[", "j", "]"}], "]"}]}], ";", " ", 
         RowBox[{"(*", 
          RowBox[{
          "Assigns", " ", "beta", " ", "in", " ", "the", " ", "right", " ", 
           "order"}], "*)"}], "\[IndentingNewLine]", 
         RowBox[{
          SubscriptBox["propN", "i"], "=", 
          RowBox[{"SetPrecision", "[", 
           RowBox[{
            RowBox[{"propNvec", "[", 
             RowBox[{"[", "j", "]"}], "]"}], ",", "acc"}], "]"}]}], ";", " ", 
         RowBox[{"(*", 
          RowBox[{
          "Assigns", " ", "beta", " ", "in", " ", "the", " ", "right", " ", 
           "order"}], "*)"}], "\[IndentingNewLine]", 
         RowBox[{
          SubscriptBox["relN0", "i"], "=", 
          RowBox[{"SetPrecision", "[", 
           RowBox[{
            FractionBox[
             SubscriptBox["propN", "i"], 
             SubscriptBox["propN", "1"]], ",", "acc"}], "]"}]}], ";", " ", 
         RowBox[{"(*", 
          RowBox[{
          "Calculate", " ", "the", " ", "proportions", " ", "of", " ", 
           "people", " ", "in", " ", "each", " ", "type", " ", "relative", 
           " ", "to", " ", "the", " ", "highest", " ", "beta", " ", "type"}], 
          "*)"}], "\[IndentingNewLine]", 
         RowBox[{
          SubscriptBox["relctilde0", "i"], "=", 
          RowBox[{"SetPrecision", "[", 
           RowBox[{
            RowBox[{
             FractionBox[
              RowBox[{
               SubscriptBox["\[Beta]", "i"], " ", 
               RowBox[{"(", 
                RowBox[{"1", "-", "\[Alpha]", "-", 
                 RowBox[{
                  SubscriptBox["\[Beta]", "1"], "*", 
                  RowBox[{"(", 
                   RowBox[{"\[Omega]", "+", 
                    RowBox[{
                    RowBox[{"(", 
                    RowBox[{"1", "-", "\[Omega]"}], ")"}], " ", 
                    RowBox[{"Piefunc", "[", "0", "]"}]}]}], ")"}]}]}], 
                ")"}]}], 
              RowBox[{
               SubscriptBox["\[Beta]", "1"], " ", 
               RowBox[{"(", 
                RowBox[{"1", "-", "\[Alpha]", "-", 
                 RowBox[{
                  SubscriptBox["\[Beta]", "i"], "*", 
                  RowBox[{"(", 
                   RowBox[{"\[Omega]", "+", 
                    RowBox[{
                    RowBox[{"(", 
                    RowBox[{"1", "-", "\[Omega]"}], ")"}], " ", 
                    RowBox[{"Piefunc", "[", "0", "]"}]}]}], ")"}]}]}], 
                ")"}]}]], "*", 
             SubscriptBox["relN0", "i"]}], ",", "acc"}], "]"}]}], ";"}]}], 
       "  ", 
       RowBox[{"(*", " ", 
        RowBox[{
        "Given", " ", "the", " ", "above", " ", "calculate", " ", "the", " ", 
         "relative", " ", "proportions", " ", "of", " ", "consumption", " ", 
         "of", " ", "each", " ", "type", " ", "relative", " ", "to", " ", 
         "the", " ", "highest", " ", "beta", " ", "type"}], "*)"}], 
       "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
       "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"afunc", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"afunc", "[", "t", "]"}], "=", 
        SubscriptBox["ax", "t"]}]}], ";", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"gDee", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"gDee", "[", "t", "]"}], "=", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"t", "\[LessEqual]", 
           RowBox[{
            RowBox[{"Length", "[", "Dee", "]"}], "-", "2"}]}], ",", 
          FractionBox[
           RowBox[{"Dee", "[", 
            RowBox[{"[", 
             RowBox[{"t", "+", "2"}], "]"}], "]"}], 
           RowBox[{"Dee", "[", 
            RowBox[{"[", 
             RowBox[{"t", "+", "1"}], "]"}], "]"}]], ",", "grDee"}], 
         "]"}]}]}], ";", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"Deefuncx", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"Deefuncx", "[", "t", "]"}], "=", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"t", "\[Equal]", 
           RowBox[{"-", "1"}]}], ",", "1", ",", 
          RowBox[{
           RowBox[{"Deefuncx", "[", 
            RowBox[{"t", "-", "1"}], "]"}], "*", 
           RowBox[{"gDee", "[", "t", "]"}]}]}], "]"}]}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"geN", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"geN", "[", "t", "]"}], "=", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"t", "\[LessEqual]", 
           RowBox[{
            RowBox[{"Length", "[", "eNdata", "]"}], "-", "2"}]}], ",", 
          FractionBox[
           RowBox[{"eNdata", "[", 
            RowBox[{"[", 
             RowBox[{"t", "+", "2"}], "]"}], "]"}], 
           RowBox[{"eNdata", "[", 
            RowBox[{"[", 
             RowBox[{"t", "+", "1"}], "]"}], "]"}]], ",", "greN"}], "]"}]}]}],
       ";", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"eN", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"eN", "[", "t", "]"}], "=", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"t", "\[Equal]", 
           RowBox[{"-", "1"}]}], ",", 
          RowBox[{"eNdata", "[", 
           RowBox[{"[", "1", "]"}], "]"}], ",", 
          RowBox[{
           RowBox[{"eN", "[", 
            RowBox[{"t", "-", "1"}], "]"}], "*", 
           RowBox[{"geN", "[", "t", "]"}]}]}], "]"}]}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"Clear", "[", 
       RowBox[{"gNss", ",", "ktildess", ",", "ass"}], "]"}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{"gNss", "=", "greN"}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"ansSS", "=", 
       RowBox[{"FindRoot", "[", 
        RowBox[{
         RowBox[{"{", 
          RowBox[{
           RowBox[{"gNss", "==", 
            RowBox[{
             RowBox[{"(", 
              RowBox[{
               RowBox[{
                RowBox[{"-", "ass"}], " ", "Piess", " ", 
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{"-", "1"}], "+", "\[Alpha]"}], ")"}], " ", 
                RowBox[{"(", 
                 RowBox[{"1", "+", 
                  RowBox[{"Piess", " ", 
                   SubscriptBox["\[Beta]", "1"], " ", 
                   RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "\[Omega]"}], ")"}]}], "-", 
                  RowBox[{
                   SubscriptBox["\[Beta]", "1"], " ", "\[Omega]"}]}], ")"}]}],
                "+", 
               RowBox[{"ktildess", " ", 
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{"-", "1"}], "+", "\[Delta]"}], ")"}], " ", 
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{"-", "1"}], "+", "\[Alpha]", "+", 
                  RowBox[{
                   SubscriptBox["\[Beta]", "1"], " ", 
                   RowBox[{"(", 
                    RowBox[{"Piess", "+", "\[Omega]", "-", 
                    RowBox[{"Piess", " ", "\[Omega]"}]}], ")"}]}]}], ")"}]}], 
               "+", 
               RowBox[{
                SuperscriptBox["ktildess", "\[Nu]"], " ", 
                RowBox[{"(", 
                 RowBox[{"1", "-", 
                  RowBox[{"Piess", " ", 
                   SubscriptBox["\[Beta]", "1"]}], "+", 
                  RowBox[{
                   RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "Piess"}], ")"}], " ", 
                   SubscriptBox["\[Beta]", "1"], " ", "\[Omega]"}], "+", 
                  RowBox[{"\[Alpha]", " ", 
                   RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", 
                    RowBox[{
                    SubscriptBox["\[Beta]", "1"], " ", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "\[Nu]"}], ")"}], " ", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "Piess"}], "+", 
                    RowBox[{
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "Piess"}], ")"}], " ", 
                    "\[Omega]"}]}], ")"}]}]}], ")"}]}]}], ")"}]}]}], ")"}], 
             "/", 
             RowBox[{"(", 
              RowBox[{"ass", "+", 
               RowBox[{"ass", " ", "Piess", " ", 
                SubscriptBox["\[Beta]", "1"], " ", 
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{"-", "1"}], "+", "\[Omega]"}], ")"}]}], "-", 
               RowBox[{"ass", " ", 
                SubscriptBox["\[Beta]", "1"], " ", "\[Omega]"}], "-", 
               RowBox[{
                SuperscriptBox["grDee", 
                 FractionBox["1", 
                  RowBox[{"1", "-", "\[Nu]"}]]], " ", "ktildess", " ", 
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{"-", "1"}], "+", "\[Alpha]", "+", 
                  RowBox[{
                   SubscriptBox["\[Beta]", "1"], " ", 
                   RowBox[{"(", 
                    RowBox[{"Piess", "+", "\[Omega]", "-", 
                    RowBox[{"Piess", " ", "\[Omega]"}]}], ")"}]}]}], 
                 ")"}]}]}], ")"}]}]}], ",", 
           RowBox[{"ktildess", "==", 
            SuperscriptBox[
             RowBox[{"(", 
              FractionBox[
               RowBox[{
                RowBox[{
                 SuperscriptBox["grDee", 
                  FractionBox["1", 
                   RowBox[{"1", "-", "\[Nu]"}]]], " ", "gNss"}], "+", 
                RowBox[{
                 RowBox[{"(", 
                  RowBox[{
                   RowBox[{"Piess", " ", 
                    RowBox[{"(", 
                    RowBox[{"1", "-", "\[Omega]"}], ")"}]}], "+", 
                   "\[Omega]"}], ")"}], " ", 
                 SubscriptBox["\[Beta]", "1"], " ", 
                 RowBox[{"(", 
                  RowBox[{
                   RowBox[{"-", "1"}], "+", "\[Delta]"}], ")"}]}]}], 
               RowBox[{
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{"Piess", " ", 
                   RowBox[{"(", 
                    RowBox[{"1", "-", "\[Omega]"}], ")"}]}], "+", 
                  "\[Omega]"}], ")"}], " ", 
                SubscriptBox["\[Beta]", "1"], " ", "\[Nu]"}]], ")"}], 
             FractionBox["1", 
              RowBox[{
               RowBox[{"-", "1"}], "+", "\[Nu]"}]]]}]}], "}"}], ",", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"{", 
            RowBox[{"ass", ",", "0.15"}], "}"}], ",", 
           RowBox[{"{", 
            RowBox[{"ktildess", ",", "0.06"}], "}"}]}], "}"}]}], "]"}]}], ";",
       "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"ass", "=", 
       RowBox[{"ass", "/.", "ansSS"}]}], ";", "\[IndentingNewLine]", 
      RowBox[{
       SubscriptBox["ax", "time"], "=", "ass"}], ";", "\[IndentingNewLine]", 
      RowBox[{
       SubscriptBox["ax", 
        RowBox[{"time", "+", "1"}]], "=", "ass"}], ";", "\[IndentingNewLine]",
       "\[IndentingNewLine]", 
      RowBox[{"ktildess", "=", 
       RowBox[{"ktildess", "/.", "ansSS"}]}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"wtilde", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"wtilde", "[", "t", "]"}], "=", 
        RowBox[{
         RowBox[{"(", 
          RowBox[{"1", "-", "\[Nu]"}], ")"}], "*", 
         SuperscriptBox[
          RowBox[{"(", 
           RowBox[{"SetPrecision", "[", 
            RowBox[{
             SubscriptBox["ktilde", "t"], ",", "acc"}], "]"}], ")"}], 
          RowBox[{"SetPrecision", "[", 
           RowBox[{"\[Nu]", ",", "acc"}], "]"}]]}]}]}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"r", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"r", "[", "t", "]"}], "=", 
        RowBox[{"\[Nu]", "*", 
         SuperscriptBox[
          RowBox[{"(", 
           RowBox[{"SetPrecision", "[", 
            RowBox[{
             SubscriptBox["ktilde", "t"], ",", "acc"}], "]"}], ")"}], 
          RowBox[{"SetPrecision", "[", 
           RowBox[{
            RowBox[{"\[Nu]", "-", "1"}], ",", "acc"}], "]"}]]}]}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"Cetilde", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"Cetilde", "[", "t", "]"}], "=", 
        RowBox[{
         SuperscriptBox[
          RowBox[{"SetPrecision", "[", 
           RowBox[{
            SubscriptBox["ktilde", "t"], ",", "acc"}], "]"}], 
          RowBox[{"SetPrecision", "[", 
           RowBox[{"\[Nu]", ",", "acc"}], "]"}]], "-", 
         RowBox[{"(", 
          RowBox[{
           RowBox[{
            RowBox[{"SetPrecision", "[", 
             RowBox[{
              SubscriptBox["gN", 
               RowBox[{"1", "+", "t"}]], ",", "acc"}], "]"}], " ", 
            SuperscriptBox[
             RowBox[{"gDee", "[", 
              RowBox[{"1", "+", "t"}], "]"}], 
             FractionBox["1", 
              RowBox[{"1", "-", "\[Nu]"}]]], " ", 
            RowBox[{"SetPrecision", "[", 
             RowBox[{
              SubscriptBox["ktilde", 
               RowBox[{"1", "+", "t"}]], ",", "acc"}], "]"}]}], "-", 
           RowBox[{
            RowBox[{"(", 
             RowBox[{"1", "-", "\[Delta]"}], ")"}], 
            RowBox[{"SetPrecision", "[", " ", 
             RowBox[{
              SubscriptBox["ktilde", "t"], ",", "acc"}], "]"}]}]}], ")"}], 
         "-", 
         RowBox[{
          RowBox[{"afunc", "[", "t", "]"}], "*", " ", 
          RowBox[{"(", 
           RowBox[{
            RowBox[{"SetPrecision", "[", 
             RowBox[{
              SubscriptBox["gN", 
               RowBox[{"1", "+", "t"}]], ",", "acc"}], "]"}], "-", 
            RowBox[{"Piefunc", "[", "t", "]"}]}], " ", ")"}]}]}]}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"relonealphabeta", "[", 
        RowBox[{"t_", ",", "j_"}], "]"}], ":=", 
       RowBox[{
        RowBox[{"relonealphabeta", "[", 
         RowBox[{"t", ",", "j"}], "]"}], "=", 
        RowBox[{"SetPrecision", "[", 
         RowBox[{
          FractionBox[
           RowBox[{"1", "-", "\[Alpha]", "-", 
            RowBox[{
             RowBox[{"SetPrecision", "[", 
              RowBox[{
               SubscriptBox["\[Beta]", "j"], ",", "acc"}], "]"}], "*", 
             RowBox[{"(", 
              RowBox[{"\[Omega]", "+", 
               RowBox[{
                RowBox[{"(", 
                 RowBox[{"1", "-", "\[Omega]"}], ")"}], " ", 
                RowBox[{"Piefunc", "[", "t", "]"}]}]}], ")"}]}]}], 
           RowBox[{"1", "-", "\[Alpha]", "-", 
            RowBox[{
             RowBox[{"SetPrecision", "[", 
              RowBox[{
               SubscriptBox["\[Beta]", "1"], ",", "acc"}], "]"}], "*", 
             RowBox[{"(", 
              RowBox[{"\[Omega]", "+", 
               RowBox[{
                RowBox[{"(", 
                 RowBox[{"1", "-", "\[Omega]"}], ")"}], " ", 
                RowBox[{"Piefunc", "[", "t", "]"}]}]}], ")"}]}]}]], ",", 
          "acc"}], "]"}]}]}], ";", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"relbeta", "[", 
        RowBox[{"t_", ",", "j_"}], "]"}], ":=", 
       RowBox[{
        RowBox[{"relbeta", "[", 
         RowBox[{"t", ",", "j"}], "]"}], "=", 
        RowBox[{"SetPrecision", "[", 
         RowBox[{
          SuperscriptBox[
           RowBox[{"(", 
            RowBox[{"SetPrecision", "[", 
             RowBox[{
              FractionBox[
               SubscriptBox["\[Beta]", "j"], 
               SubscriptBox["\[Beta]", "1"]], ",", "acc"}], "]"}], ")"}], 
           "t"], ",", "acc"}], "]"}]}]}], ";", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"helper", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"helper", "[", "t", "]"}], "=", 
        RowBox[{"(", 
         RowBox[{"1", "+", 
          RowBox[{
           UnderoverscriptBox["\[Sum]", 
            RowBox[{"j", "=", "2"}], "nTypes"], 
           RowBox[{"(", 
            RowBox[{
             SubscriptBox["relN0", "j"], "*", 
             RowBox[{"relbeta", "[", 
              RowBox[{"t", ",", "j"}], "]"}], "*", 
             FractionBox[
              RowBox[{"relonealphabeta", "[", 
               RowBox[{"t", ",", "j"}], "]"}], 
              RowBox[{" ", 
               RowBox[{"relonealphabeta", "[", 
                RowBox[{"0", ",", "j"}], "]"}]}]]}], ")"}]}]}], ")"}]}]}], 
      ";", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"helper2", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"helper2", "[", "t", "]"}], "=", 
        RowBox[{"(", 
         RowBox[{"1", "+", 
          RowBox[{
           UnderoverscriptBox["\[Sum]", 
            RowBox[{"j", "=", "2"}], "nTypes"], 
           RowBox[{
            SubscriptBox["relctilde0", "j"], "*", 
            RowBox[{"relbeta", "[", 
             RowBox[{"t", ",", "j"}], "]"}]}]}]}], ")"}]}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"eqs1", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{
         RowBox[{
          SubscriptBox["\[Beta]", "1"], 
          RowBox[{"(", 
           RowBox[{"\[Omega]", "+", 
            RowBox[{
             RowBox[{"(", 
              RowBox[{"1", "-", "\[Omega]"}], ")"}], " ", 
             RowBox[{"Piefunc", "[", 
              RowBox[{"t", "+", "1"}], "]"}]}]}], ")"}], 
          RowBox[{"(", 
           RowBox[{
            RowBox[{"(", 
             RowBox[{"1", "-", "\[Delta]"}], ")"}], "+", 
            RowBox[{"r", "[", 
             RowBox[{"t", "+", "1"}], "]"}]}], ")"}], 
          FractionBox[
           RowBox[{"helper2", "[", 
            RowBox[{"t", "+", "1"}], "]"}], 
           RowBox[{"helper2", "[", "t", "]"}]], 
          RowBox[{"Cetilde", "[", "t", "]"}]}], "-", 
         RowBox[{
          RowBox[{"Cetilde", "[", 
           RowBox[{"t", "+", "1"}], "]"}], "*", 
          SuperscriptBox[
           RowBox[{"gDee", "[", 
            RowBox[{"t", "+", "1"}], "]"}], 
           FractionBox["1", 
            RowBox[{"1", "-", "\[Nu]"}]]], 
          SubscriptBox["gN", 
           RowBox[{"t", "+", "1"}]]}]}], "\[Equal]", "0"}]}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"eqs2", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{
         RowBox[{"\[Alpha]", " ", 
          SubscriptBox["\[Beta]", "1"], 
          RowBox[{"(", 
           RowBox[{"\[Omega]", "+", 
            RowBox[{
             RowBox[{"(", 
              RowBox[{"1", "-", "\[Omega]"}], ")"}], " ", 
             RowBox[{"Piefunc", "[", 
              RowBox[{"t", "+", "1"}], "]"}]}]}], ")"}], 
          RowBox[{"(", 
           RowBox[{
            RowBox[{"wtilde", "[", 
             RowBox[{"1", "+", "t"}], "]"}], "+", 
            RowBox[{
             RowBox[{"Piefunc", "[", 
              RowBox[{"t", "+", "1"}], "]"}], "*", 
             RowBox[{"afunc", "[", 
              RowBox[{"t", "+", "1"}], "]"}]}]}], ")"}], "*", 
          RowBox[{"Cetilde", "[", "t", "]"}]}], "+", 
         RowBox[{
          RowBox[{"(", 
           RowBox[{"1", "-", "\[Alpha]", "-", 
            RowBox[{
             SubscriptBox["\[Beta]", "1"], 
             RowBox[{"(", 
              RowBox[{"\[Omega]", "+", 
               RowBox[{
                RowBox[{"(", 
                 RowBox[{"1", "-", "\[Omega]"}], ")"}], " ", 
                RowBox[{"Piefunc", "[", 
                 RowBox[{"t", "+", "1"}], "]"}]}]}], ")"}]}]}], ")"}], 
          FractionBox[
           RowBox[{"helper", "[", 
            RowBox[{"t", "+", "1"}], "]"}], 
           RowBox[{"helper2", "[", 
            RowBox[{"t", "+", "1"}], "]"}]], "*", 
          RowBox[{"Cetilde", "[", 
           RowBox[{"t", "+", "1"}], "]"}], "*", 
          RowBox[{"Cetilde", "[", "t", "]"}]}], "-", 
         RowBox[{"\[Alpha]", " ", 
          RowBox[{"Cetilde", "[", 
           RowBox[{"t", "+", "1"}], "]"}], 
          SubscriptBox["gN", 
           RowBox[{"t", "+", "1"}]], "*", 
          RowBox[{"afunc", "[", "t", "]"}], "*", 
          FractionBox[
           RowBox[{"helper2", "[", "t", "]"}], 
           RowBox[{"helper2", "[", 
            RowBox[{"t", "+", "1"}], "]"}]]}]}], "\[Equal]", "0"}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{
       SubscriptBox["gN", 
        RowBox[{"time", "+", "1"}]], "=", "gNss"}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{
       SubscriptBox["ktilde", 
        RowBox[{"time", "+", "1"}]], "=", "ktildess"}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"For", "[", 
       RowBox[{
        RowBox[{"i", "=", "0"}], ",", 
        RowBox[{"i", "\[LessEqual]", "time"}], ",", 
        RowBox[{"i", "++"}], ",", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{
          SubscriptBox["gN", "i"], "=", 
          RowBox[{"geN", "[", "i", "]"}]}], ";"}]}], "\[IndentingNewLine]", 
       "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"If", "[", 
       RowBox[{
        RowBox[{
         RowBox[{"Length", "[", "pVector", "]"}], "\[Equal]", "19"}], ",", 
        "\[IndentingNewLine]", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"answerTemp", "=", 
          RowBox[{"FindRoot", "[", 
           RowBox[{
            RowBox[{"Join", "[", 
             RowBox[{
              RowBox[{"Table", "[", 
               RowBox[{
                RowBox[{"eqs2", "[", "t", "]"}], ",", 
                RowBox[{"{", 
                 RowBox[{"t", ",", 
                  RowBox[{"-", "1"}], ",", 
                  RowBox[{"time", "-", "1"}]}], "}"}]}], "]"}], ",", 
              RowBox[{"Table", "[", 
               RowBox[{
                RowBox[{"eqs1", "[", "t", "]"}], ",", 
                RowBox[{"{", 
                 RowBox[{"t", ",", 
                  RowBox[{"-", "1"}], ",", 
                  RowBox[{"time", "-", "1"}]}], "}"}]}], "]"}]}], "]"}], ",", 
            RowBox[{"Join", "[", 
             RowBox[{
              RowBox[{"Table", "[", 
               RowBox[{
                RowBox[{"{", 
                 RowBox[{
                  SubscriptBox["ax", "i"], ",", 
                  RowBox[{"(", 
                   RowBox[{
                    SubscriptBox["ax", "i"], "/.", "initPoint"}], ")"}]}], 
                 "}"}], ",", 
                RowBox[{"{", 
                 RowBox[{"i", ",", 
                  RowBox[{"-", "1"}], ",", 
                  RowBox[{"time", "-", "1"}]}], "}"}]}], "]"}], ",", 
              RowBox[{"Table", "[", 
               RowBox[{
                RowBox[{"{", 
                 RowBox[{
                  SubscriptBox["ktilde", "i"], ",", 
                  RowBox[{"(", 
                   RowBox[{
                    SubscriptBox["ktilde", "i"], "/.", "initPoint"}], ")"}]}],
                  "}"}], ",", 
                RowBox[{"{", 
                 RowBox[{"i", ",", "0", ",", "time"}], "}"}]}], "]"}]}], 
             "]"}], ",", 
            RowBox[{"MaxIterations", "\[Rule]", "1000"}]}], "]"}]}], ";"}], 
        "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
        ",", "\[IndentingNewLine]", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"answerTemp", "=", 
          RowBox[{"FindRoot", "[", 
           RowBox[{
            RowBox[{"Join", "[", 
             RowBox[{
              RowBox[{"Table", "[", 
               RowBox[{
                RowBox[{"eqs2", "[", "t", "]"}], ",", 
                RowBox[{"{", 
                 RowBox[{"t", ",", 
                  RowBox[{"-", "1"}], ",", 
                  RowBox[{"time", "-", "1"}]}], "}"}]}], "]"}], ",", 
              RowBox[{"Table", "[", 
               RowBox[{
                RowBox[{"eqs1", "[", "t", "]"}], ",", 
                RowBox[{"{", 
                 RowBox[{"t", ",", 
                  RowBox[{"-", "1"}], ",", 
                  RowBox[{"time", "-", "1"}]}], "}"}]}], "]"}]}], "]"}], ",", 
            RowBox[{"Join", "[", 
             RowBox[{
              RowBox[{"Table", "[", 
               RowBox[{
                RowBox[{"{", 
                 RowBox[{
                  SubscriptBox["ax", "i"], ",", "0.3"}], "}"}], ",", 
                RowBox[{"{", 
                 RowBox[{"i", ",", 
                  RowBox[{"-", "1"}], ",", 
                  RowBox[{"time", "-", "1"}]}], "}"}]}], "]"}], ",", 
              RowBox[{"Table", "[", 
               RowBox[{
                RowBox[{"{", 
                 RowBox[{
                  SubscriptBox["ktilde", "i"], ",", "0.07"}], "}"}], ",", 
                RowBox[{"{", 
                 RowBox[{"i", ",", "0", ",", "time"}], "}"}]}], "]"}]}], 
             "]"}], ",", 
            RowBox[{"MaxIterations", "\[Rule]", "1000"}]}], "]"}]}], ";"}]}], 
       "\[IndentingNewLine]", "\[IndentingNewLine]", "]"}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"Nii", "[", 
        RowBox[{"i_", ",", "t_"}], "]"}], ":=", 
       RowBox[{
        RowBox[{"Nii", "[", 
         RowBox[{"i", ",", "t"}], "]"}], "=", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"t", "\[LessEqual]", "time"}], ",", 
          RowBox[{
           FractionBox[
            RowBox[{"(", 
             RowBox[{
              SubscriptBox["relN0", "i"], "*", 
              RowBox[{"relbeta", "[", 
               RowBox[{"t", ",", "i"}], "]"}], "*", 
              FractionBox[
               RowBox[{"relonealphabeta", "[", 
                RowBox[{"t", ",", "i"}], "]"}], 
               RowBox[{"relonealphabeta", "[", 
                RowBox[{"0", ",", "i"}], "]"}]]}], ")"}], 
            RowBox[{"helper", "[", "t", "]"}]], "*", 
           RowBox[{"eN", "[", "t", "]"}]}], ",", 
          RowBox[{"If", "[", 
           RowBox[{
            RowBox[{"i", "\[Equal]", "1"}], ",", 
            RowBox[{"eN", "[", "t", "]"}], ",", "0"}], "]"}]}], "]"}]}]}], 
      ";", 
      RowBox[{
       RowBox[{"citilde", "[", 
        RowBox[{"i_", ",", "t_"}], "]"}], ":=", 
       RowBox[{
        RowBox[{"citilde", "[", 
         RowBox[{"i", ",", "t"}], "]"}], "=", 
        RowBox[{
         RowBox[{
          FractionBox[
           RowBox[{
            SubscriptBox["relctilde0", "i"], "*", 
            RowBox[{"relbeta", "[", 
             RowBox[{"t", ",", "i"}], "]"}]}], 
           RowBox[{"helper2", "[", "t", "]"}]], "*", 
          RowBox[{"Cetilde", "[", "t", "]"}]}], "/.", "answerTemp"}]}]}], ";",
       "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"If", "[", 
       RowBox[{
        RowBox[{"evaluatePercentiles", "==", "1"}], ",", 
        "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"For", "[", 
          RowBox[{
           RowBox[{"i", "=", "1"}], ",", 
           RowBox[{"i", "\[LessEqual]", "nTypes"}], ",", 
           RowBox[{"i", "++"}], ",", "\[IndentingNewLine]", 
           "\[IndentingNewLine]", 
           RowBox[{
            RowBox[{"If", "[", 
             RowBox[{
              RowBox[{"i", "\[Equal]", "1"}], ",", 
              RowBox[{
               SubscriptBox["kitilde", 
                RowBox[{"i", ",", 
                 RowBox[{"time", "+", "1"}]}]], "=", "ktildess"}], ",", 
              RowBox[{
               SubscriptBox["kitilde", 
                RowBox[{"i", ",", 
                 RowBox[{"time", "+", "1"}]}]], "=", "0"}]}], "]"}], ";"}]}], 
          "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", 
         "\[IndentingNewLine]", 
         RowBox[{
          RowBox[{"eqs3", "[", 
           RowBox[{"i_", ",", "t_"}], "]"}], ":=", 
          RowBox[{
           RowBox[{
            SubscriptBox["kitilde", 
             RowBox[{"i", ",", "t"}]], "==", 
            FractionBox[
             RowBox[{
              RowBox[{"citilde", "[", 
               RowBox[{"i", ",", "t"}], "]"}], "-", 
              RowBox[{
               RowBox[{"(", 
                RowBox[{
                 RowBox[{"wtilde", "[", "t", "]"}], "+", 
                 RowBox[{
                  RowBox[{"afunc", "[", "t", "]"}], "*", 
                  RowBox[{"Piefunc", "[", "t", "]"}]}]}], ")"}], "*", 
               FractionBox[
                RowBox[{"Nii", "[", 
                 RowBox[{"i", ",", "t"}], "]"}], 
                RowBox[{"eN", "[", "t", "]"}]]}], "+", 
              RowBox[{
               SubscriptBox["gN", 
                RowBox[{"t", "+", "1"}]], 
               RowBox[{"(", 
                RowBox[{
                 RowBox[{
                  RowBox[{"afunc", "[", "t", "]"}], "*", 
                  FractionBox[
                   RowBox[{"Nii", "[", 
                    RowBox[{"i", ",", 
                    RowBox[{"t", "+", "1"}]}], "]"}], 
                   RowBox[{"eN", "[", 
                    RowBox[{"t", "+", "1"}], "]"}]]}], "+", 
                 RowBox[{
                  SubscriptBox["kitilde", 
                   RowBox[{"i", ",", 
                    RowBox[{"t", "+", "1"}]}]], "*", 
                  SuperscriptBox[
                   RowBox[{"gDee", "[", 
                    RowBox[{"t", "+", "1"}], "]"}], 
                   FractionBox["1", 
                    RowBox[{"1", "-", "\[Nu]"}]]]}]}], ")"}]}]}], 
             RowBox[{"(", 
              RowBox[{"1", "-", "\[Delta]", "+", 
               RowBox[{"r", "[", "t", "]"}]}], ")"}]]}], "/.", 
           "answerTemp"}]}], ";", "\[IndentingNewLine]", 
         "\[IndentingNewLine]", 
         RowBox[{"answerkitilde", "=", 
          RowBox[{"Table", "[", 
           RowBox[{
            RowBox[{"Solve", "[", 
             RowBox[{
              RowBox[{"Table", "[", 
               RowBox[{
                RowBox[{"eqs3", "[", 
                 RowBox[{"j", ",", "t"}], "]"}], ",", 
                RowBox[{"{", 
                 RowBox[{"t", ",", "0", ",", "time"}], "}"}]}], "]"}], ",", 
              RowBox[{"Table", "[", 
               RowBox[{
                SubscriptBox["kitilde", 
                 RowBox[{"j", ",", "t"}]], ",", 
                RowBox[{"{", 
                 RowBox[{"t", ",", "0", ",", "time"}], "}"}]}], "]"}]}], 
             "]"}], ",", 
            RowBox[{"{", 
             RowBox[{"j", ",", "1", ",", "nTypes"}], "}"}]}], "]"}]}], ";", 
         "\[IndentingNewLine]", 
         RowBox[{
          RowBox[{"kiitilde", "[", 
           RowBox[{"i_", ",", "t_"}], "]"}], ":=", 
          RowBox[{
           RowBox[{"kiitilde", "[", 
            RowBox[{"i", ",", "t"}], "]"}], "=", 
           RowBox[{"answerkitilde", "[", 
            RowBox[{"[", 
             RowBox[{"i", ",", "1", ",", 
              RowBox[{"t", "+", "1"}], ",", "2"}], "]"}], "]"}]}]}], ";", 
         "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
         "\[IndentingNewLine]", 
         RowBox[{"indexpct", "=", 
          RowBox[{"Join", "[", 
           RowBox[{
            RowBox[{"{", "0", "}"}], ",", 
            RowBox[{"Quantile", "[", 
             RowBox[{
              RowBox[{"Table", "[", 
               RowBox[{"i", ",", 
                RowBox[{"{", 
                 RowBox[{"i", ",", "1", ",", "nTypes"}], "}"}]}], "]"}], ",", 
              RowBox[{"Table", "[", 
               RowBox[{
                FractionBox["i", "pct"], ",", 
                RowBox[{"{", 
                 RowBox[{"i", ",", "1", ",", "pct"}], "}"}]}], "]"}]}], 
             "]"}]}], "]"}]}], ";", "\[IndentingNewLine]", 
         "\[IndentingNewLine]", 
         RowBox[{
          RowBox[{"Nij", "[", 
           RowBox[{"i_", ",", "j_"}], "]"}], ":=", 
          RowBox[{"Table", "[", 
           RowBox[{
            RowBox[{
             SubscriptBox[
              RowBox[{"ToExpression", "[", 
               RowBox[{"(", 
                RowBox[{"\"\<NQ\>\"", "<>", 
                 RowBox[{"ToString", "[", "\[IndentingNewLine]", 
                  RowBox[{"(", 
                   RowBox[{
                    RowBox[{"Position", "[", 
                    RowBox[{"indexpct", ",", 
                    RowBox[{"i", "-", "1"}]}], "]"}], "[", 
                    RowBox[{"[", 
                    RowBox[{"1", ",", "1"}], "]"}], "]"}], ")"}], "]"}]}], 
                ")"}], "]"}], "t"], "\[Rule]", 
             RowBox[{"(", 
              FractionBox[
               RowBox[{
                UnderoverscriptBox["\[Sum]", 
                 RowBox[{"k", "=", "i"}], "j"], 
                RowBox[{"Nii", "[", 
                 RowBox[{"k", ",", "t"}], "]"}]}], 
               RowBox[{"eN", "[", "t", "]"}]], ")"}]}], ",", 
            RowBox[{"{", 
             RowBox[{"t", ",", "0", ",", "time"}], "}"}]}], "]"}]}], ";", 
         "\[IndentingNewLine]", "\[IndentingNewLine]", 
         RowBox[{
          RowBox[{"Kij", "[", 
           RowBox[{"i_", ",", "j_"}], "]"}], ":=", 
          RowBox[{"Table", "[", 
           RowBox[{
            RowBox[{
             SubscriptBox[
              RowBox[{"ToExpression", "[", 
               RowBox[{"(", 
                RowBox[{"\"\<KQ\>\"", "<>", 
                 RowBox[{"ToString", "[", "\[IndentingNewLine]", 
                  RowBox[{"(", 
                   RowBox[{
                    RowBox[{"Position", "[", 
                    RowBox[{"indexpct", ",", 
                    RowBox[{"i", "-", "1"}]}], "]"}], "[", 
                    RowBox[{"[", 
                    RowBox[{"1", ",", "1"}], "]"}], "]"}], ")"}], "]"}]}], 
                ")"}], "]"}], "t"], "\[Rule]", 
             RowBox[{"(", 
              FractionBox[
               RowBox[{
                UnderoverscriptBox["\[Sum]", 
                 RowBox[{"k", "=", "i"}], "j"], 
                RowBox[{"kiitilde", "[", 
                 RowBox[{"k", ",", "t"}], "]"}]}], 
               SubscriptBox["ktilde", "t"]], ")"}]}], ",", 
            RowBox[{"{", 
             RowBox[{"t", ",", "0", ",", "time"}], "}"}]}], "]"}]}], ";", 
         "\[IndentingNewLine]", "\[IndentingNewLine]", 
         RowBox[{"answerNQuantiles", "=", 
          RowBox[{
           RowBox[{"Table", "[", 
            RowBox[{
             RowBox[{"Nij", "[", 
              RowBox[{
               RowBox[{
                RowBox[{"indexpct", "[", 
                 RowBox[{"[", "i", "]"}], "]"}], "+", "1"}], ",", 
               RowBox[{"indexpct", "[", 
                RowBox[{"[", 
                 RowBox[{"i", "+", "1"}], "]"}], "]"}]}], "]"}], ",", 
             RowBox[{"{", 
              RowBox[{"i", ",", "1", ",", "pct"}], "}"}]}], "]"}], "/.", 
           "answerTemp"}]}], ";", "\[IndentingNewLine]", 
         RowBox[{"answerKQuantiles", "=", 
          RowBox[{
           RowBox[{"Table", "[", 
            RowBox[{
             RowBox[{"Kij", "[", 
              RowBox[{
               RowBox[{
                RowBox[{"indexpct", "[", 
                 RowBox[{"[", "i", "]"}], "]"}], "+", "1"}], ",", 
               RowBox[{"indexpct", "[", 
                RowBox[{"[", 
                 RowBox[{"i", "+", "1"}], "]"}], "]"}]}], "]"}], ",", 
             RowBox[{"{", 
              RowBox[{"i", ",", "1", ",", "pct"}], "}"}]}], "]"}], "/.", 
           "answerTemp"}]}], ";"}]}], "\[IndentingNewLine]", 
       "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"answery", "=", 
       RowBox[{"Table", "[", 
        RowBox[{
         RowBox[{
          SubscriptBox["y", "t"], "\[Rule]", 
          RowBox[{
           RowBox[{"Deefuncx", "[", "t", "]"}], "*", 
           SuperscriptBox[
            RowBox[{"(", 
             RowBox[{
              SuperscriptBox[
               RowBox[{"Deefuncx", "[", "t", "]"}], 
               FractionBox["1", 
                RowBox[{"1", "-", "\[Nu]"}]]], "*", 
              RowBox[{"eN", "[", "t", "]"}], "*", 
              RowBox[{"(", 
               RowBox[{
                SubscriptBox["ktilde", "t"], "/.", "answerTemp"}], ")"}]}], 
             ")"}], "\[Nu]"], 
           SuperscriptBox[
            RowBox[{"eN", "[", "t", "]"}], 
            RowBox[{"-", "\[Nu]"}]]}]}], ",", 
         RowBox[{"{", 
          RowBox[{"t", ",", 
           RowBox[{"-", "1"}], ",", "time"}], "}"}]}], "]"}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"answerR", "=", 
       RowBox[{
        RowBox[{"Table", "[", 
         RowBox[{
          RowBox[{
           SubscriptBox["R", "t"], "\[Rule]", 
           RowBox[{"1", "-", "\[Delta]", "+", 
            RowBox[{"r", "[", "t", "]"}]}]}], ",", 
          RowBox[{"{", 
           RowBox[{"t", ",", "0", ",", "time"}], "}"}]}], "]"}], "/.", 
        "answerTemp"}]}], ";", "\[IndentingNewLine]", 
      RowBox[{
       SubscriptBox["ax", "time"], "=."}], ";", "\[IndentingNewLine]", 
      RowBox[{"answera", "=", 
       RowBox[{"Join", "[", 
        RowBox[{
         RowBox[{"Table", "[", 
          RowBox[{
           RowBox[{
            SubscriptBox["ax", "t"], "\[Rule]", 
            RowBox[{"(", 
             RowBox[{
              SubscriptBox["ax", "t"], "/.", "answerTemp"}], ")"}]}], ",", 
           RowBox[{"{", 
            RowBox[{"t", ",", 
             RowBox[{"-", "1"}], ",", 
             RowBox[{"time", "-", "1"}]}], "}"}]}], "]"}], ",", 
         RowBox[{"{", 
          RowBox[{
           SubscriptBox["ax", "time"], "\[Rule]", "ass"}], "}"}]}], "]"}]}], 
      ";", "\[IndentingNewLine]", 
      RowBox[{"answerCtildeAg", "=", 
       RowBox[{
        RowBox[{"Table", "[", 
         RowBox[{
          RowBox[{
           SubscriptBox["Ctildeag", "t"], "\[Rule]", 
           RowBox[{"Cetilde", "[", "t", "]"}]}], ",", 
          RowBox[{"{", 
           RowBox[{"t", ",", "0", ",", "time"}], "}"}]}], "]"}], "/.", 
        "answerTemp"}]}], ";", "\[IndentingNewLine]", 
      RowBox[{"answerN", "=", 
       RowBox[{"Table", "[", 
        RowBox[{
         RowBox[{
          SubscriptBox["N", "t"], "\[Rule]", 
          RowBox[{"eN", "[", "t", "]"}]}], ",", 
         RowBox[{"{", 
          RowBox[{"t", ",", "0", ",", "time"}], "}"}]}], "]"}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"answersavingsrate", "=", 
       RowBox[{"Table", "[", 
        RowBox[{
         RowBox[{
          SubscriptBox["s", "t"], "\[Rule]", 
          RowBox[{
           RowBox[{"(", 
            RowBox[{
             RowBox[{
              SuperscriptBox[
               RowBox[{"Deefuncx", "[", 
                RowBox[{"t", "+", "1"}], "]"}], 
               FractionBox["1", 
                RowBox[{"1", "-", "\[Nu]"}]]], "*", 
              RowBox[{"eN", "[", 
               RowBox[{"t", "+", "1"}], "]"}], "*", 
              RowBox[{"(", 
               RowBox[{
                SubscriptBox["ktilde", 
                 RowBox[{"t", "+", "1"}]], "/.", "answerTemp"}], ")"}]}], "-", 
             RowBox[{
              RowBox[{"(", 
               RowBox[{"1", "-", "\[Delta]"}], ")"}], "*", 
              SuperscriptBox[
               RowBox[{"Deefuncx", "[", "t", "]"}], 
               FractionBox["1", 
                RowBox[{"1", "-", "\[Nu]"}]]], "*", 
              RowBox[{"eN", "[", "t", "]"}], "*", 
              RowBox[{"(", 
               RowBox[{
                SubscriptBox["ktilde", "t"], "/.", "answerTemp"}], ")"}]}]}], 
            ")"}], "/", 
           RowBox[{"(", 
            RowBox[{
             RowBox[{"Deefuncx", "[", "t", "]"}], "*", 
             SuperscriptBox[
              RowBox[{"(", 
               RowBox[{
                SuperscriptBox[
                 RowBox[{"Deefuncx", "[", "t", "]"}], 
                 FractionBox["1", 
                  RowBox[{"1", "-", "\[Nu]"}]]], "*", 
                RowBox[{"eN", "[", "t", "]"}], "*", 
                RowBox[{"(", 
                 RowBox[{
                  SubscriptBox["ktilde", "t"], "/.", "answerTemp"}], ")"}]}], 
               ")"}], "\[Nu]"], 
             SuperscriptBox[
              RowBox[{"eN", "[", "t", "]"}], 
              RowBox[{"1", "-", "\[Nu]"}]]}], ")"}]}]}], ",", 
         RowBox[{"{", 
          RowBox[{"t", ",", "0", ",", "time"}], "}"}]}], "]"}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"temp", "=", 
       SubscriptBox["ktilde", 
        RowBox[{"-", "1"}]]}], ";", "\[IndentingNewLine]", 
      RowBox[{
       SubscriptBox["ktilde", 
        RowBox[{"-", "1"}]], "=."}], ";", "\[IndentingNewLine]", 
      RowBox[{"answerktilde", "=", 
       RowBox[{"Table", "[", 
        RowBox[{
         RowBox[{
          SubscriptBox["ktilde", "t"], "\[Rule]", 
          RowBox[{"(", 
           RowBox[{
            SubscriptBox["ktilde", "t"], "/.", "answerTemp"}], ")"}]}], ",", 
         RowBox[{"{", 
          RowBox[{"t", ",", "0", ",", "time"}], "}"}]}], "]"}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"answerD", "=", 
       RowBox[{"Table", "[", 
        RowBox[{
         RowBox[{
          SubscriptBox["D", "t"], "\[Rule]", 
          RowBox[{"Deefuncx", "[", "t", "]"}]}], ",", 
         RowBox[{"{", 
          RowBox[{"t", ",", "0", ",", "time"}], "}"}]}], "]"}]}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{"answerK", "=", 
       RowBox[{"Table", "[", 
        RowBox[{
         RowBox[{
          SubscriptBox["K", "t"], "\[Rule]", 
          RowBox[{
           SuperscriptBox[
            RowBox[{"Deefuncx", "[", "t", "]"}], 
            FractionBox["1", 
             RowBox[{"1", "-", "\[Nu]"}]]], "*", 
           RowBox[{"eN", "[", "t", "]"}], "*", 
           RowBox[{"(", 
            RowBox[{
             SubscriptBox["ktilde", "t"], "/.", "answerTemp"}], ")"}]}]}], 
         ",", 
         RowBox[{"{", 
          RowBox[{"t", ",", "0", ",", "time"}], "}"}]}], "]"}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"answerFert", "=", 
       RowBox[{"Table", "[", 
        RowBox[{
         RowBox[{
          SubscriptBox["f", "t"], "\[Rule]", 
          RowBox[{"(", 
           RowBox[{
            RowBox[{"(", 
             FractionBox[
              RowBox[{"eN", "[", 
               RowBox[{"t", "+", "1"}], "]"}], 
              RowBox[{"eN", "[", "t", "]"}]], ")"}], "-", 
            RowBox[{"Piefunc", "[", "t", "]"}]}], ")"}]}], ",", 
         RowBox[{"{", 
          RowBox[{"t", ",", "0", ",", "time"}], "}"}]}], "]"}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"answerY", "=", 
       RowBox[{"Table", "[", 
        RowBox[{
         RowBox[{
          SubscriptBox["Y", "t"], "\[Rule]", 
          RowBox[{
           RowBox[{"Deefuncx", "[", "t", "]"}], "*", 
           SuperscriptBox[
            RowBox[{"(", 
             RowBox[{
              SuperscriptBox[
               RowBox[{"Deefuncx", "[", "t", "]"}], 
               FractionBox["1", 
                RowBox[{"1", "-", "\[Nu]"}]]], "*", 
              RowBox[{"eN", "[", "t", "]"}], "*", 
              RowBox[{"(", 
               RowBox[{
                SubscriptBox["ktilde", "t"], "/.", "answerTemp"}], ")"}]}], 
             ")"}], "\[Nu]"], 
           SuperscriptBox[
            RowBox[{"eN", "[", "t", "]"}], 
            RowBox[{"1", "-", "\[Nu]"}]]}]}], ",", 
         RowBox[{"{", 
          RowBox[{"t", ",", "0", ",", "time"}], "}"}]}], "]"}]}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{"answerwNrK", "=", 
       RowBox[{"Table", "[", 
        RowBox[{
         RowBox[{
          SubscriptBox["wNrK", "t"], "\[Rule]", 
          RowBox[{"(", 
           RowBox[{
            RowBox[{
             RowBox[{"(", 
              RowBox[{
               RowBox[{"r", "[", "t", "]"}], "/.", "answerTemp"}], ")"}], "*", 
             SuperscriptBox[
              RowBox[{"Deefuncx", "[", "t", "]"}], 
              FractionBox["1", 
               RowBox[{"1", "-", "\[Nu]"}]]], "*", 
             RowBox[{"eN", "[", "t", "]"}], "*", 
             RowBox[{"(", 
              RowBox[{
               SubscriptBox["ktilde", "t"], "/.", "answerTemp"}], ")"}]}], 
            "+", 
            RowBox[{
             RowBox[{"(", 
              RowBox[{
               RowBox[{"wtilde", "[", "t", "]"}], "/.", "answerTemp"}], ")"}],
              "*", 
             SuperscriptBox[
              RowBox[{"Deefuncx", "[", "t", "]"}], 
              FractionBox["1", 
               RowBox[{"1", "-", "\[Nu]"}]]], 
             RowBox[{"eN", "[", "t", "]"}]}]}], ")"}]}], ",", 
         RowBox[{"{", 
          RowBox[{"t", ",", "0", ",", "time"}], "}"}]}], "]"}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"If", "[", 
       RowBox[{
        RowBox[{"evaluatePercentiles", "==", "1"}], ",", 
        "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"answer", "=", 
          RowBox[{"Join", "[", 
           RowBox[{
            RowBox[{"{", "answerR", "}"}], ",", 
            RowBox[{"{", "answera", "}"}], ",", 
            RowBox[{"{", "answerN", "}"}], ",", 
            RowBox[{"{", "answerktilde", "}"}], ",", 
            RowBox[{"{", "answerK", "}"}], ",", 
            RowBox[{"{", "answerD", "}"}], ",", 
            RowBox[{"{", "answery", "}"}], ",", 
            RowBox[{"{", "answerCtildeAg", "}"}], ",", 
            RowBox[{"{", 
             RowBox[{"Table", "[", 
              RowBox[{
               RowBox[{
                SubscriptBox["Ni", 
                 RowBox[{"j", ",", "28"}]], "\[Rule]", "xxx"}], 
               RowBox[{"(*", 
                RowBox[{"Nii", "[", 
                 RowBox[{"j", ",", "28"}], "]"}], "*)"}], ",", 
               RowBox[{"{", 
                RowBox[{"j", ",", "1", ",", "nTypes"}], "}"}]}], "]"}], "}"}],
             ",", 
            RowBox[{"{", "answersavingsrate", "}"}], ",", 
            RowBox[{"{", "answerFert", "}"}], ",", 
            RowBox[{"{", "answerY", "}"}], ",", 
            RowBox[{"{", "answerwNrK", "}"}], ",", 
            RowBox[{"{", "answerNQuantiles", "}"}], ",", 
            RowBox[{"{", "answerKQuantiles", "}"}]}], "]"}]}], ";"}], 
        "\[IndentingNewLine]", ",", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"answer", "=", 
          RowBox[{"Join", "[", 
           RowBox[{
            RowBox[{"{", "answerR", "}"}], ",", 
            RowBox[{"{", "answera", "}"}], ",", 
            RowBox[{"{", "answerN", "}"}], ",", 
            RowBox[{"{", "answerktilde", "}"}], ",", 
            RowBox[{"{", "answerK", "}"}], ",", 
            RowBox[{"{", "answerD", "}"}], ",", 
            RowBox[{"{", "answery", "}"}], ",", 
            RowBox[{"{", "answerCtildeAg", "}"}], ",", 
            RowBox[{"{", 
             RowBox[{"Table", "[", 
              RowBox[{
               RowBox[{
                SubscriptBox["Ni", 
                 RowBox[{"j", ",", "28"}]], "\[Rule]", "xxx"}], 
               RowBox[{"(*", 
                RowBox[{"Nii", "[", 
                 RowBox[{"j", ",", "28"}], "]"}], "*)"}], ",", 
               RowBox[{"{", 
                RowBox[{"j", ",", "1", ",", "nTypes"}], "}"}]}], "]"}], "}"}],
             ",", 
            RowBox[{"{", "answersavingsrate", "}"}], ",", 
            RowBox[{"{", "answerFert", "}"}], ",", 
            RowBox[{"{", "answerY", "}"}], ",", 
            RowBox[{"{", "answerwNrK", "}"}]}], "]"}]}], ";"}]}], 
       "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       SubscriptBox["ktilde", 
        RowBox[{"time", "+", "1"}]], "=."}], ";", "\[IndentingNewLine]", 
      RowBox[{
       SubscriptBox["gN", 
        RowBox[{"time", "+", "1"}]], "=."}], ";", "\[IndentingNewLine]", 
      RowBox[{
       SubscriptBox["ax", 
        RowBox[{"time", "+", "1"}]], "=."}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"For", "[", 
       RowBox[{
        RowBox[{"i", "=", "1"}], ",", 
        RowBox[{"i", "\[LessEqual]", "nTypes"}], ",", 
        RowBox[{"i", "++"}], ",", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{
          SubscriptBox["relN0", "i"], "=."}], ";", 
         RowBox[{
          SubscriptBox["propN", "i"], "=."}], ";", 
         RowBox[{
          SubscriptBox["\[Beta]", "i"], "=."}], ";", 
         RowBox[{
          SubscriptBox["relctilde0", "i"], "=."}], ";"}]}], 
       "\[IndentingNewLine]", "\[IndentingNewLine]", "]"}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"For", "[", 
       RowBox[{
        RowBox[{"i", "=", "0"}], ",", 
        RowBox[{"i", "\[LessEqual]", "time"}], ",", 
        RowBox[{"i", "++"}], ",", "\[IndentingNewLine]", 
        "\[IndentingNewLine]", 
        RowBox[{
         SubscriptBox["gN", "i"], "=."}]}], "\[IndentingNewLine]", 
       "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"Return", "[", "answer", "]"}], ";"}]}], "\[IndentingNewLine]", 
    "]"}]}], ";"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.},
 CellChangeTimes->{{3.5450207567370634`*^9, 3.5450208126640635`*^9}, {
   3.5450213922850633`*^9, 3.545021455795063*^9}, {3.545021499609063*^9, 
   3.5450218859630632`*^9}, {3.545022337398063*^9, 3.545022363188063*^9}, {
   3.545022412753063*^9, 3.545022418451063*^9}, {3.545022458470063*^9, 
   3.545022462352063*^9}, {3.5450226095130634`*^9, 3.5450226831710634`*^9}, {
   3.5450227685530634`*^9, 3.545022796658063*^9}, {3.5450231576000633`*^9, 
   3.545023168904063*^9}, 3.545023328852063*^9, {3.5450235965720634`*^9, 
   3.545023615297063*^9}, 3.545023671896063*^9, 3.545025304915063*^9, {
   3.5452319574236*^9, 3.5452319810069494`*^9}, 3.5452320377051926`*^9, 
   3.5452324327457876`*^9, {3.546864863835182*^9, 3.546864899611182*^9}, 
   3.546864971144182*^9, {3.5468650373641825`*^9, 3.5468650609311824`*^9}, {
   3.546866633771182*^9, 3.5468666428381824`*^9}, {3.5468666796221824`*^9, 
   3.5468666868411827`*^9}, {3.5469414861762*^9, 3.5469414947692003`*^9}, 
   3.5471129347887774`*^9, {3.547113040450777*^9, 3.547113044292777*^9}, 
   3.5471181898287773`*^9, {3.547118969707777*^9, 3.547118976816777*^9}, {
   3.5471212301287775`*^9, 3.547121236237777*^9}, {3.547122382551777*^9, 
   3.547122390632777*^9}, {3.547127642744777*^9, 3.547127646376777*^9}, 
   3.5471281319847775`*^9, {3.547132407191777*^9, 3.547132413044777*^9}, {
   3.547133054195777*^9, 3.547133091931777*^9}, {3.547137681165777*^9, 
   3.5471376947607775`*^9}, 3.547137748890777*^9, {3.7244196368117094`*^9, 
   3.7244196690585537`*^9}, {3.7244199852736397`*^9, 3.72442000432973*^9}, 
   3.7244200575997767`*^9, {3.7244202517508817`*^9, 3.7244202524669228`*^9}, {
   3.7244202983375463`*^9, 3.7244202987585707`*^9}, {3.724422768788848*^9, 
   3.724422780798535*^9}, {3.724423196621319*^9, 3.7244232028736763`*^9}, {
   3.7244235236850257`*^9, 3.724423541280032*^9}, {3.724423603039564*^9, 
   3.724423603252577*^9}, {3.72442401819231*^9, 3.7244240721423955`*^9}, {
   3.724425328541513*^9, 3.72442533083232*^9}, {3.724479631636307*^9, 
   3.7244799070073957`*^9}, {3.7244800117084045`*^9, 3.724480165149476*^9}, {
   3.724480222995779*^9, 3.7244802376004047`*^9}, {3.724480279496479*^9, 
   3.724480318614748*^9}, {3.724480412895115*^9, 3.7244804508971825`*^9}, {
   3.7244804896596518`*^9, 3.7244805495495577`*^9}, {3.7244805910118313`*^9, 
   3.724480611153466*^9}, {3.724480755982724*^9, 3.7244807590715294`*^9}, {
   3.7244808686808624`*^9, 3.7244808847459183`*^9}, {3.724480916247033*^9, 
   3.7244809360271125`*^9}, {3.724480976263264*^9, 3.724480994060331*^9}, {
   3.7244810560325747`*^9, 3.724481194781082*^9}, {3.7244812255951834`*^9, 
   3.7244813092584925`*^9}, 3.724482642624999*^9, {3.724499784183713*^9, 
   3.7244997889219847`*^9}, {3.724499898947277*^9, 3.7244999067877254`*^9}, {
   3.724500319348323*^9, 3.72450032175146*^9}, {3.724580135076105*^9, 
   3.7245801734072976`*^9}, {3.7259716811998024`*^9, 
   3.7259717026180277`*^9}, {3.7259718195847178`*^9, 3.725971881274246*^9}, {
   3.7259720133337994`*^9, 3.7259720446285896`*^9}, {3.7259728538058715`*^9, 
   3.72597285464992*^9}, {3.725973025874714*^9, 3.725973038702447*^9}, {
   3.7259732006057076`*^9, 3.7259732305034175`*^9}, {3.7259734422325277`*^9, 
   3.725973443425596*^9}, {3.7259736826442785`*^9, 3.725973712402981*^9}, 
   3.725974082252135*^9, {3.725974168099045*^9, 3.725974171697251*^9}, {
   3.725974276747259*^9, 3.7259743103661823`*^9}, {3.725974496668838*^9, 
   3.725974498521944*^9}, 3.7259748561053967`*^9, {3.725975127455917*^9, 
   3.7259751291570144`*^9}, {3.725975210171648*^9, 3.7259752119847517`*^9}, {
   3.725975252817087*^9, 3.7259752548932056`*^9}, {3.7259752864320097`*^9, 
   3.725975289801203*^9}, 3.725975322131052*^9, 3.7259753545829077`*^9, {
   3.7259754974490795`*^9, 3.7259755232805567`*^9}, {3.725975563454855*^9, 
   3.725975588667297*^9}, 3.725975645441544*^9, 3.725975912794836*^9, {
   3.7259767322667065`*^9, 3.7259767777723093`*^9}, {3.7259768351155896`*^9, 
   3.72597683948584*^9}, {3.7259770115736823`*^9, 3.7259770124347315`*^9}, {
   3.725977843585271*^9, 3.7259778513217134`*^9}, 3.7259780865771694`*^9, {
   3.7259782106042633`*^9, 3.725978215138522*^9}, {3.725979573613223*^9, 
   3.725979578259488*^9}, {3.7259796622902946`*^9, 3.7259796627033186`*^9}, {
   3.7259797689373946`*^9, 3.7259797707714996`*^9}, {3.725982056292224*^9, 
   3.7259820623565702`*^9}, {3.7259823008802137`*^9, 3.725982304503421*^9}, 
   3.7259824300226*^9, {3.7259826255427833`*^9, 3.725982633688249*^9}, 
   3.726052533189146*^9, 3.72605654642269*^9, {3.726056584168849*^9, 
   3.726056584394862*^9}, {3.726056735840524*^9, 3.726056842057599*^9}, {
   3.7260569594213123`*^9, 3.726057006338996*^9}, {3.7260573801133747`*^9, 
   3.726057415089375*^9}, {3.7260576067103353`*^9, 3.726057621991209*^9}, {
   3.726057705075961*^9, 3.726057745505274*^9}, {3.7260577882457185`*^9, 
   3.726057788350724*^9}, 3.7260578532684374`*^9, {3.726058168965494*^9, 
   3.726058191954809*^9}, 3.7260584572559834`*^9, 3.7260585510203466`*^9, 
   3.7260586693901167`*^9, {3.7260587136876507`*^9, 3.7260587150287275`*^9}, 
   3.7260587885099297`*^9, {3.7260588803901854`*^9, 3.7260588874085865`*^9}, {
   3.726065395157809*^9, 3.7260654081495523`*^9}, 3.7260656730857053`*^9, 
   3.7261505320115995`*^9, {3.726150817149908*^9, 3.7261508223902082`*^9}, {
   3.7261508610924215`*^9, 3.726150863175541*^9}, {3.7261509226079397`*^9, 
   3.7261509268461823`*^9}, {3.7261510114810233`*^9, 3.7261510127760973`*^9}, 
   3.7261510472260675`*^9, 3.726151239068041*^9, {3.7262219221653395`*^9, 
   3.7262219459126973`*^9}, {3.726572778538774*^9, 3.72657296396938*^9}, {
   3.726575277551709*^9, 3.7265753263424997`*^9}, {3.72657919038251*^9, 
   3.726579245115641*^9}, {3.726579328005382*^9, 3.7265793459474087`*^9}, {
   3.7265794571257677`*^9, 3.7265794576507974`*^9}, {3.7265799193752065`*^9, 
   3.726580062607399*^9}, {3.7265802511051807`*^9, 3.726580253477316*^9}, {
   3.7265802907774496`*^9, 3.7265803011860447`*^9}, 3.726580332100813*^9, 
   3.726580472134823*^9, {3.7266782584229593`*^9, 3.7266782584839625`*^9}, {
   3.7266783520883164`*^9, 3.726678380217925*^9}, {3.7266784821867576`*^9, 
   3.7266784823207655`*^9}, {3.7266787722723494`*^9, 3.726678775699546*^9}, {
   3.7267378871756425`*^9, 3.7267378926259546`*^9}, {3.7267380012321663`*^9, 
   3.7267380443816347`*^9}, 3.7267383395445166`*^9, {3.7267386874814177`*^9, 
   3.726738687681429*^9}, {3.7267444538442345`*^9, 3.7267444738113766`*^9}, {
   3.7267445078853254`*^9, 3.7267445116465406`*^9}, {3.7267457891266084`*^9, 
   3.726745799611208*^9}, 3.726745894313625*^9, {3.7267459474936666`*^9, 
   3.7267459805325565`*^9}, {3.7267460135954475`*^9, 3.72674601364145*^9}, {
   3.7267460666484814`*^9, 3.7267461243247805`*^9}, {3.726746174803668*^9, 
   3.7267461757657228`*^9}, {3.726746250501998*^9, 3.7267462517090664`*^9}, {
   3.726746297312675*^9, 3.726746303088005*^9}, {3.7267463504067116`*^9, 
   3.726746381343481*^9}, {3.7267464139183445`*^9, 3.7267464155854397`*^9}, {
   3.7267464517585087`*^9, 3.7267464864564934`*^9}, 3.726819600791639*^9, {
   3.7268197192754154`*^9, 3.726819719388422*^9}, {3.7268198949364634`*^9, 
   3.72681997041078*^9}, {3.72682000135955*^9, 3.726820003057647*^9}, 
   3.72691757275277*^9, {3.727072630144998*^9, 3.7270726344392433`*^9}, {
   3.7270727025001364`*^9, 3.7270727041672316`*^9}, {3.7270728599741435`*^9, 
   3.727072918786507*^9}, {3.7270729491822457`*^9, 3.7270729909026318`*^9}, {
   3.727073513310512*^9, 3.727073542136161*^9}, {3.727074679458212*^9, 
   3.7270748814547653`*^9}, {3.727075074493807*^9, 3.7270750745778117`*^9}, {
   3.7270945860178022`*^9, 3.7270946626231833`*^9}, {3.7270947251547604`*^9, 
   3.727094761848859*^9}, {3.7270947954997835`*^9, 3.7270948121007333`*^9}, {
   3.7270948538851233`*^9, 3.7270949068631535`*^9}, {3.7270950033696733`*^9, 
   3.727095089821618*^9}, 3.727095232651553*^9, {3.7270952690986376`*^9, 
   3.727095271704787*^9}, {3.727095339118643*^9, 3.7270953396516733`*^9}, {
   3.727095959410121*^9, 3.7270959750520163`*^9}, {3.7270961075605946`*^9, 
   3.7270961520811415`*^9}, {3.727096333395512*^9, 3.7270963427230453`*^9}, {
   3.7270965519610133`*^9, 3.7270966642324347`*^9}, {3.7270967194025908`*^9, 
   3.7270967202946415`*^9}, 3.7270969294026017`*^9, {3.7271625649643507`*^9, 
   3.7271625827703686`*^9}, {3.727162660482814*^9, 3.7271626620939054`*^9}, {
   3.727163375511711*^9, 3.727163405971453*^9}, {3.7271634883771667`*^9, 
   3.7271634889061966`*^9}, {3.727163542124241*^9, 3.7271635923131113`*^9}, {
   3.7271643657323484`*^9, 3.727164372091712*^9}, {3.7271644136430883`*^9, 
   3.7271644879673395`*^9}, 3.727164521644266*^9, {3.727174777862838*^9, 
   3.7271747779968452`*^9}, {3.727359715845685*^9, 3.7273597179218035`*^9}, {
   3.7273599821989193`*^9, 3.7273599829359617`*^9}, 3.7273601710737224`*^9, 
   3.727362167636919*^9, {3.7274230101644087`*^9, 3.727423014298645*^9}, {
   3.727440638677702*^9, 3.7274406636271296`*^9}, 3.7274406964070044`*^9, 
   3.727440731352003*^9, {3.7274407796657662`*^9, 3.7274408067343144`*^9}, {
   3.727510206731958*^9, 3.72751020764401*^9}, 3.7275103904494658`*^9, {
   3.727527978340436*^9, 3.727528016145598*^9}, {3.727535745583697*^9, 
   3.7275357715461817`*^9}, {3.7275519585534515`*^9, 3.727551999871815*^9}, {
   3.727552131153324*^9, 3.7275522351042695`*^9}, {3.727552655918339*^9, 
   3.7275527050771503`*^9}, {3.727552771365942*^9, 3.727552784072669*^9}, {
   3.72755285070848*^9, 3.727552853584645*^9}, {3.727554772658409*^9, 
   3.7275547869542274`*^9}, 3.7610435364817405`*^9, {3.761043571231025*^9, 
   3.761043576165954*^9}, {3.7610436235881033`*^9, 3.7610436413449106`*^9}, {
   3.7610436729002457`*^9, 3.761043770878871*^9}, {3.7610438475156293`*^9, 
   3.7610438647290735`*^9}, {3.7610443741135235`*^9, 3.761044401042234*^9}, {
   3.7618924178069444`*^9, 3.761892420698386*^9}, {3.761892490182556*^9, 
   3.7618924929984612`*^9}, {3.761892545538104*^9, 3.761892574421073*^9}, {
   3.7618943501822863`*^9, 3.761894355806435*^9}, 3.7618944420269365`*^9, {
   3.761894590484105*^9, 3.7618945909553003`*^9}, {3.765706575514555*^9, 
   3.7657065967311754`*^9}, {3.7657069762490983`*^9, 3.765706998624098*^9}, {
   3.7657827346196156`*^9, 3.7657827346804476`*^9}, {3.7657827662081413`*^9, 
   3.765782776262255*^9}, {3.7657828291219053`*^9, 3.7657829030262814`*^9}, {
   3.765792704839733*^9, 3.765792713891528*^9}, {3.7657927941309633`*^9, 
   3.765792854728921*^9}, {3.7657928892486134`*^9, 3.7657929295766582`*^9}, {
   3.765792979001932*^9, 3.7657930204449406`*^9}, {3.7657931294908957`*^9, 
   3.7657931374256454`*^9}, {3.7657931713717318`*^9, 
   3.7657931859776144`*^9}, {3.7657939720100403`*^9, 
   3.7657941210305495`*^9}, {3.7657941752425876`*^9, 
   3.7657942749356403`*^9}, {3.7657943083572693`*^9, 3.765794317829939*^9}, 
   3.76579434791549*^9, {3.765794438973993*^9, 3.7657945077181673`*^9}, {
   3.765795044879264*^9, 3.7657950752816195`*^9}, 3.7657960529456987`*^9, 
   3.7657973933299627`*^9, 3.765866685458251*^9, {3.765866741061284*^9, 
   3.7658667423029637`*^9}, {3.7658675605738115`*^9, 3.765867632896985*^9}, {
   3.76586808998555*^9, 3.7658681576486278`*^9}, {3.765870398400258*^9, 
   3.765870398502982*^9}, {3.765870746165774*^9, 3.765870746206662*^9}, {
   3.765874668191653*^9, 3.765874668660451*^9}, {3.7658747061050673`*^9, 
   3.765874729806857*^9}, {3.765875398319106*^9, 3.765875401117617*^9}, {
   3.765876280541726*^9, 3.76587629695483*^9}, {3.7658763346779566`*^9, 
   3.765876338007025*^9}, {3.765876902981591*^9, 3.7658769609724207`*^9}, {
   3.7658770973194704`*^9, 3.7658770998766603`*^9}, {3.7658771811591372`*^9, 
   3.7658771850627003`*^9}, {3.7658772670901785`*^9, 
   3.7658772777028255`*^9}, {3.765877315014012*^9, 3.765877352872703*^9}, {
   3.765877425541308*^9, 3.765877426344161*^9}, {3.76587748017918*^9, 
   3.765877480255975*^9}, {3.7658775192685795`*^9, 3.765877539390752*^9}, {
   3.7658776192561045`*^9, 3.7658776350189996`*^9}, {3.765877844409308*^9, 
   3.7658778654739313`*^9}, {3.7658781572475634`*^9, 
   3.7658781732168517`*^9}, {3.7658785536763487`*^9, 
   3.7658785537621183`*^9}, {3.765878723204729*^9, 3.7658787278354254`*^9}, {
   3.765878821034837*^9, 3.765878824716008*^9}, {3.7658788602087345`*^9, 
   3.765878906257386*^9}, {3.7658789742188053`*^9, 3.765878977583871*^9}, {
   3.7658790137815223`*^9, 3.7658790168971925`*^9}, {3.7658799376814375`*^9, 
   3.7658799503366623`*^9}, {3.7658802835697455`*^9, 3.765880284330738*^9}, {
   3.7658803589922943`*^9, 3.7658803634055367`*^9}, {3.7658803953571463`*^9, 
   3.765880397842506*^9}, {3.765880428410843*^9, 3.7658804292576137`*^9}, {
   3.7658805076082697`*^9, 3.765880507758868*^9}, {3.7658805416603003`*^9, 
   3.765880560977695*^9}, {3.7658806147939253`*^9, 3.7658806186366596`*^9}, {
   3.765880689523216*^9, 3.7658807745617647`*^9}, {3.7658808085188737`*^9, 
   3.7658808113652554`*^9}, {3.7658808656150513`*^9, 
   3.7658808672945523`*^9}, {3.765884258963793*^9, 3.765884276245948*^9}, {
   3.7658848692984433`*^9, 3.765884895979295*^9}, {3.765884941039137*^9, 
   3.7658849467099524`*^9}, {3.7658850008335857`*^9, 
   3.7658850086916256`*^9}, {3.765885087197223*^9, 3.765885102892359*^9}, {
   3.767001403833307*^9, 3.767001408035447*^9}, 3.767072356048971*^9, {
   3.7670724191411943`*^9, 3.7670724494980583`*^9}, {3.768893865727254*^9, 
   3.768893891122732*^9}, {3.7688945439884176`*^9, 3.768894544740034*^9}, {
   3.7688945986450815`*^9, 3.7688946343340454`*^9}, {3.768894749355147*^9, 
   3.7688947878920264`*^9}, {3.7688949238677526`*^9, 3.768894954747985*^9}, {
   3.7689038263403683`*^9, 3.7689038282929125`*^9}, {3.768903915431242*^9, 
   3.7689039197578783`*^9}, {3.768904091492632*^9, 3.7689041150608983`*^9}, {
   3.7689041650389643`*^9, 3.768904182034179*^9}, {3.768905401412935*^9, 
   3.7689054035910573`*^9}, {3.7689054852734146`*^9, 
   3.7689055132666073`*^9}, {3.76890561559*^9, 3.768905636101339*^9}, {
   3.7689984908949623`*^9, 3.768998492197207*^9}, {3.7689986706032896`*^9, 
   3.7689986707504272`*^9}, 3.76900051144162*^9, {3.769667292429305*^9, 
   3.76966732283525*^9}, {3.769667411801306*^9, 3.7696674128681464`*^9}, {
   3.7696674494975157`*^9, 3.7696674771269746`*^9}, {3.7696675279533386`*^9, 
   3.769667536844982*^9}, {3.7696675837476463`*^9, 3.769667587877054*^9}, {
   3.7697477473142405`*^9, 3.7697477641227903`*^9}, {3.769747797271249*^9, 
   3.7697478544453297`*^9}, {3.769748134123003*^9, 3.7697481445893335`*^9}, {
   3.7697482343182077`*^9, 3.769748238411008*^9}, {3.769748280697935*^9, 
   3.7697482912423325`*^9}, {3.7697490009661984`*^9, 
   3.7697490204772377`*^9}, {3.7697490770108285`*^9, 
   3.7697491081128883`*^9}, {3.7697492058243017`*^9, 3.769749224460558*^9}, {
   3.7697492789165*^9, 3.769749297896429*^9}, {3.7697493449166307`*^9, 
   3.7697493610846944`*^9}, 3.769750101598489*^9, {3.769752151792632*^9, 
   3.769752271978362*^9}, {3.7697524382321973`*^9, 3.7697524960300493`*^9}, {
   3.7697530394500003`*^9, 3.769753092035779*^9}, {3.769753178265218*^9, 
   3.7697532130028305`*^9}, {3.7697532703222885`*^9, 3.769753292540619*^9}, {
   3.7697533741636252`*^9, 3.769753436044987*^9}, {3.7697535132179327`*^9, 
   3.769753516665329*^9}, 3.7697535818502827`*^9, {3.769922030223013*^9, 
   3.769922053699747*^9}, {3.7699224451857543`*^9, 3.769922486638294*^9}, {
   3.7699254723034325`*^9, 3.769925473271984*^9}, {3.771660100115201*^9, 
   3.7716601062800055`*^9}, {3.77166053487606*^9, 3.7716606259878173`*^9}, {
   3.7716623761238966`*^9, 3.7716623779596643`*^9}, {3.7716678911254325`*^9, 
   3.7716679089924345`*^9}, {3.7716679454177*^9, 3.77166799233274*^9}, {
   3.7716695970190773`*^9, 3.771669600389398*^9}, {3.771677568982067*^9, 
   3.7716775766050835`*^9}, {3.7716782969564185`*^9, 3.771678360053693*^9}, {
   3.7716784267759666`*^9, 3.7716784284344177`*^9}, {3.7716784911055613`*^9, 
   3.771678522673049*^9}, {3.7716785548654757`*^9, 3.771678589214897*^9}, {
   3.7716796500115128`*^9, 3.7716796836316442`*^9}, {3.771743068876005*^9, 
   3.7717430689298563`*^9}, {3.77174466019594*^9, 3.7717446622579923`*^9}, {
   3.771755638956787*^9, 3.7717556494710464`*^9}, {3.7717557338724613`*^9, 
   3.7717558208535852`*^9}, {3.7717564613961935`*^9, 3.771756483394667*^9}, {
   3.7717565588132677`*^9, 3.7717565847653637`*^9}, {3.771758180176942*^9, 
   3.7717581952406173`*^9}, {3.7719282620047493`*^9, 3.771928274281084*^9}, {
   3.773053676650999*^9, 3.773053690522129*^9}, 3.773063978148549*^9, {
   3.7731234898213634`*^9, 3.7731235282751245`*^9}, {3.775375371997332*^9, 
   3.7753753755161343`*^9}, {3.775381879597662*^9, 3.7753820307799625`*^9}, {
   3.7753822258368473`*^9, 3.775382269230371*^9}, {3.775382400406457*^9, 
   3.7753824182754817`*^9}, 3.775382551223713*^9, {3.77597032999426*^9, 
   3.775970330447278*^9}, {3.7759705888399467`*^9, 3.775970721027199*^9}, {
   3.7759710485869637`*^9, 3.7759710887198963`*^9}, {3.775971474224698*^9, 
   3.7759714748964148`*^9}, {3.775971532707755*^9, 3.7759715330955353`*^9}, {
   3.7759721163234186`*^9, 3.7759721173075643`*^9}, {3.7759738730554285`*^9, 
   3.7759740309008923`*^9}, {3.7759748008302064`*^9, 3.775974913086027*^9}, {
   3.7759750283600225`*^9, 3.775975032209963*^9}, {3.7759751833425517`*^9, 
   3.7759751865228715`*^9}, {3.7759754025482993`*^9, 3.77597544571861*^9}, {
   3.7759755157361407`*^9, 3.7759756273651576`*^9}, {3.7759757606940885`*^9, 
   3.775975784107974*^9}, {3.775976434150741*^9, 3.775976467643176*^9}, {
   3.7759765378057933`*^9, 3.775976600400424*^9}, {3.7759767817857*^9, 
   3.775976802977689*^9}, {3.77597691101481*^9, 3.7759769237682476`*^9}, {
   3.775977046928296*^9, 3.7759770513506327`*^9}, {3.775977139852575*^9, 
   3.7759772599952807`*^9}, {3.7759773025624247`*^9, 3.775977342687679*^9}, {
   3.775977809838889*^9, 3.775977812310458*^9}, {3.775978173456747*^9, 
   3.775978182960619*^9}, {3.7759783529285316`*^9, 3.7759783732318764`*^9}, {
   3.7759784908419094`*^9, 3.7759785383017845`*^9}, {3.7759787050729647`*^9, 
   3.7759787148939123`*^9}, {3.775978815087892*^9, 3.77597881521286*^9}, {
   3.775978887670947*^9, 3.7759789094696665`*^9}, {3.7759789669034915`*^9, 
   3.775978966965975*^9}, {3.77597905925445*^9, 3.77597905939504*^9}, {
   3.77597931651031*^9, 3.7759793438810096`*^9}, {3.775979393248663*^9, 
   3.775979396861303*^9}, {3.775979493900787*^9, 3.775979498870141*^9}, {
   3.7759795704519544`*^9, 3.7759795719515963`*^9}, {3.775980367498499*^9, 
   3.775980373688101*^9}, {3.7759804334722986`*^9, 3.7759804394118643`*^9}, {
   3.775980470034383*^9, 3.7759804759416084`*^9}, {3.7759805213187113`*^9, 
   3.7759805265232625`*^9}, {3.775980596710368*^9, 3.775980597866354*^9}, {
   3.775980685440336*^9, 3.775980701194945*^9}, {3.775980801032648*^9, 
   3.7759808040813193`*^9}, {3.775980906504019*^9, 3.775980943761853*^9}, {
   3.7759810222523394`*^9, 3.775981029988222*^9}, {3.775981071593402*^9, 
   3.775981137893276*^9}, {3.7759812064539804`*^9, 3.7759812173457317`*^9}, {
   3.775981267186038*^9, 3.7759812889275665`*^9}, {3.775981367822196*^9, 
   3.7759813933659244`*^9}, {3.7759814908037863`*^9, 3.775981512309603*^9}, {
   3.775982191035874*^9, 3.775982270888726*^9}, {3.775982659747901*^9, 
   3.775982715980893*^9}, {3.775983088714069*^9, 3.7759831014937725`*^9}, {
   3.775983479476821*^9, 3.775983494015912*^9}, {3.775984157083788*^9, 
   3.775984189105794*^9}, {3.775987638218315*^9, 3.775987669492136*^9}, {
   3.7759877882950287`*^9, 3.7759878103737164`*^9}, {3.7759879407630053`*^9, 
   3.77598794732751*^9}, {3.7759884426335487`*^9, 3.7759884433833733`*^9}, {
   3.7759903836128483`*^9, 3.7759903891335106`*^9}, {3.775990536786618*^9, 
   3.775990537630173*^9}, {3.775991052511698*^9, 3.77599109547548*^9}, {
   3.776056992233425*^9, 3.776057069303294*^9}, {3.776057153335003*^9, 
   3.7760571823878765`*^9}, {3.7760572182036057`*^9, 
   3.7760573256045346`*^9}, {3.77605742420984*^9, 3.7760574270080004`*^9}, {
   3.7760575890959277`*^9, 3.7760576223432865`*^9}, {3.776057657480855*^9, 
   3.776057745252927*^9}, {3.7760577990605288`*^9, 3.7760578380112743`*^9}, {
   3.7760604287191863`*^9, 3.77606046598678*^9}, {3.7760619884688883`*^9, 
   3.776062072334055*^9}, {3.7760627885494223`*^9, 3.7760627981098127`*^9}, {
   3.7760750179446545`*^9, 3.776075020666136*^9}, {3.7764888645709724`*^9, 
   3.7764889098753557`*^9}, {3.776489328125409*^9, 3.7764893391100535`*^9}, {
   3.77649131423363*^9, 3.7764913192681317`*^9}, {3.7764916880966997`*^9, 
   3.776491723375167*^9}, {3.7764926384497523`*^9, 3.7764927740143375`*^9}, {
   3.7764928183674555`*^9, 3.7764928867245255`*^9}, {3.7764945679353523`*^9, 
   3.7764946137514715`*^9}, {3.776495453736725*^9, 3.776495503977549*^9}, 
   3.7764955944029465`*^9, {3.776496911278183*^9, 3.7764969331721306`*^9}, 
   3.7764973570621305`*^9, {3.7764983447840176`*^9, 3.7764984575630236`*^9}, 
   3.7764985889090443`*^9, {3.776499585795329*^9, 3.776499585982813*^9}, {
   3.7764996323471537`*^9, 3.7764996341553574`*^9}, {3.7765011925631084`*^9, 
   3.776501230502634*^9}, 3.776501264702818*^9, {3.7765046444826655`*^9, 
   3.7765046472113724`*^9}, {3.776507174468521*^9, 3.7765072183103795`*^9}, 
   3.7765080755665674`*^9, {3.7782235757323546`*^9, 3.778223577241416*^9}, {
   3.7789220404263115`*^9, 3.7789220630006003`*^9}, 3.7789221044667997`*^9, {
   3.7789221359072857`*^9, 3.7789221586896644`*^9}, {3.7789237311543007`*^9, 
   3.7789237591190524`*^9}, {3.793018120756835*^9, 3.793018123576969*^9}, {
   3.7930181900905676`*^9, 3.7930181940923815`*^9}, 3.793035980039872*^9, {
   3.793106335043481*^9, 3.7931063531114197`*^9}, {3.7931164191303134`*^9, 
   3.7931164223439703`*^9}, {3.7967322254312787`*^9, 
   3.7967322355513597`*^9}, {3.850815071901292*^9, 3.850815145662879*^9}, {
   3.850815197881313*^9, 3.8508152428672905`*^9}, {3.8508157635682344`*^9, 
   3.850815764572797*^9}, 3.8508158040356255`*^9, {3.8508159263986874`*^9, 
   3.850815999633526*^9}, {3.8508163057829022`*^9, 3.850816437935964*^9}, {
   3.8508165313410544`*^9, 3.8508165578528976`*^9}, {3.8508172704911513`*^9, 
   3.8508173648959455`*^9}, {3.8508174125181413`*^9, 3.850817448754005*^9}, {
   3.850817524639171*^9, 3.850817542477711*^9}, {3.8508178137828074`*^9, 
   3.850817909907736*^9}, {3.850817951898738*^9, 3.850817977069121*^9}, {
   3.850818028669967*^9, 3.850818051351202*^9}, {3.8508181159191933`*^9, 
   3.8508182065049405`*^9}, {3.8508182806895823`*^9, 3.850818289336316*^9}, {
   3.8508183258070726`*^9, 3.8508183278359127`*^9}, {3.8508183612051325`*^9, 
   3.850818518286129*^9}, 3.8508187239545207`*^9, {3.8508191343984995`*^9, 
   3.8508191719869356`*^9}, {3.850819203089984*^9, 3.8508192378455715`*^9}, {
   3.850819374412201*^9, 3.8508194645888433`*^9}, {3.8508195601210756`*^9, 
   3.8508195638604155`*^9}, {3.850819624672181*^9, 3.8508196262779903`*^9}, {
   3.850820859240729*^9, 3.8508208774604807`*^9}, {3.8508209194455457`*^9, 
   3.8508209194960556`*^9}, {3.8508209926938763`*^9, 
   3.8508210759473886`*^9}, {3.8508212992217264`*^9, 3.850821351212199*^9}, {
   3.8508213849875965`*^9, 3.850821385270567*^9}, {3.8508214317950125`*^9, 
   3.850821431826255*^9}, {3.850821766102844*^9, 3.850821766322113*^9}, {
   3.850821869018364*^9, 3.8508218695507617`*^9}, {3.851066448608245*^9, 
   3.851066571604802*^9}, {3.8510677122401686`*^9, 3.8510677202160645`*^9}, {
   3.8510677602121325`*^9, 3.8510677603168793`*^9}, {3.851068299298009*^9, 
   3.8510683006971684`*^9}, {3.851068361487043*^9, 3.8510683615503273`*^9}, {
   3.8510684160078335`*^9, 3.8510684183915997`*^9}, {3.851244497790783*^9, 
   3.851244498786951*^9}, {3.851244626091014*^9, 3.851244714202984*^9}, {
   3.851245150163892*^9, 3.8512451920731745`*^9}, {3.8512452716592216`*^9, 
   3.851245310134405*^9}, {3.851245398444007*^9, 3.8512454339756737`*^9}, {
   3.8512454742038546`*^9, 3.851245487566362*^9}, {3.851245575998826*^9, 
   3.851245587367607*^9}, {3.851245638407413*^9, 3.8512456473975353`*^9}, {
   3.8512457116661315`*^9, 3.8512457514701896`*^9}, {3.8512458350424633`*^9, 
   3.8512458355652323`*^9}, {3.8512460437177954`*^9, 
   3.8512460526177845`*^9}, {3.851246833264872*^9, 3.851246839328143*^9}, 
   3.8515073074169846`*^9, {3.8515843192092533`*^9, 3.8515844129961185`*^9}, {
   3.851585337198927*^9, 3.851585360372138*^9}, {3.851585431525842*^9, 
   3.8515854316039305`*^9}, {3.8515854820832176`*^9, 
   3.8515855703664465`*^9}, {3.8515930943493557`*^9, 3.851593116326378*^9}, {
   3.8515989505738935`*^9, 3.8515990154321346`*^9}, {3.8515995803717666`*^9, 
   3.8515996267197533`*^9}, {3.8515996713801394`*^9, 
   3.8515996800113115`*^9}, {3.8515997363257847`*^9, 3.85159999931383*^9}, {
   3.851600033455225*^9, 3.851600134416837*^9}, {3.8516010606418095`*^9, 
   3.8516010688388968`*^9}, 3.8516011500463095`*^9, 3.851601215675002*^9, 
   3.851601279457867*^9, {3.8516013097126813`*^9, 3.851601317392064*^9}, {
   3.8516013588555727`*^9, 3.8516013713631744`*^9}, {3.8516014666488047`*^9, 
   3.851601478681609*^9}, {3.8516025452004075`*^9, 3.851602548415313*^9}, {
   3.851602820176403*^9, 3.8516028465755615`*^9}, {3.8516033373950195`*^9, 
   3.8516034345210996`*^9}, {3.851621545072527*^9, 3.851621548374962*^9}, {
   3.8516779381472816`*^9, 3.8516779864021745`*^9}, {3.8516780826477985`*^9, 
   3.851678083654154*^9}, {3.8516781334958196`*^9, 3.851678146322188*^9}, {
   3.851678232375604*^9, 3.851678237254529*^9}, 3.8516782689105024`*^9, {
   3.851678465799469*^9, 3.851678503397095*^9}, {3.8516785920857687`*^9, 
   3.8516785930712414`*^9}, {3.8516786286088343`*^9, 
   3.8516786354899387`*^9}, {3.8516786883465385`*^9, 3.85167869810627*^9}, {
   3.851678748116455*^9, 3.8516787543592625`*^9}, {3.851678811164028*^9, 
   3.8516788220481887`*^9}, {3.8517717832289643`*^9, 3.851771813727523*^9}, {
   3.8520192743399525`*^9, 3.852019379160453*^9}, {3.8520194170292535`*^9, 
   3.8520194213815265`*^9}, {3.852019457415291*^9, 3.8520194574756126`*^9}, {
   3.852019504114106*^9, 3.8520195463216925`*^9}, {3.852370973631966*^9, 
   3.8523710001138687`*^9}, 3.8523726445015216`*^9, {3.8523727353964796`*^9, 
   3.8523727484400077`*^9}, {3.852372791898356*^9, 3.8523728532164497`*^9}, {
   3.8523728971737595`*^9, 3.852372899772915*^9}, {3.8523729319196367`*^9, 
   3.8523729414218884`*^9}, {3.8523729718712206`*^9, 
   3.8523730143618307`*^9}, {3.8526358241261435`*^9, 
   3.8526358330001802`*^9}, {3.8526395447297506`*^9, 3.852639548220919*^9}, {
   3.8630862493517284`*^9, 3.8630862719769983`*^9}, {3.8630881882553988`*^9, 
   3.863088208072644*^9}, {3.8630894702658124`*^9, 3.8630894722184815`*^9}, {
   3.86351768537838*^9, 3.863517735920988*^9}, 3.894355433126083*^9, {
   3.89435619291395*^9, 3.894356213612858*^9}, {3.89435624432856*^9, 
   3.894356294931017*^9}, {3.8943563432035513`*^9, 3.894356354866317*^9}, {
   3.89435640842599*^9, 3.8943564154093237`*^9}, {3.894356453901175*^9, 
   3.8943564585416317`*^9}, {3.894356492234269*^9, 3.894356505102729*^9}, {
   3.894356575445203*^9, 3.894356599431712*^9}, {3.894356718083803*^9, 
   3.894356725280818*^9}, {3.894356793769631*^9, 3.894356815522719*^9}, {
   3.894356902844515*^9, 3.894356938880728*^9}, {3.894356986675679*^9, 
   3.894356994042242*^9}, {3.894358383139464*^9, 3.894358386837929*^9}, {
   3.894360858693782*^9, 3.89436086237257*^9}, {3.894428874233198*^9, 
   3.8944288757796087`*^9}, 3.894429267987933*^9, 3.894598675247448*^9, {
   3.8949628393715878`*^9, 3.8949628985267677`*^9}, {3.8949631164846992`*^9, 
   3.894963116853416*^9}, {3.894963405460121*^9, 3.894963407901166*^9}, {
   3.8949637647530193`*^9, 3.8949637891672297`*^9}, {3.8949638302535458`*^9, 
   3.894963843007197*^9}, 3.8949640691256*^9, {3.89496450365071*^9, 
   3.894964513788651*^9}, {3.894964861542099*^9, 3.894964861691476*^9}, {
   3.8949651462950363`*^9, 3.894965156337188*^9}, 3.894965201134613*^9, {
   3.894965437876664*^9, 3.8949654509984922`*^9}, {3.8949658758313932`*^9, 
   3.8949658783391933`*^9}, {3.894965908476426*^9, 3.894965959668703*^9}, 
   3.89496622668543*^9, {3.894966504565908*^9, 3.8949665050682087`*^9}, {
   3.89496690009731*^9, 3.894966902087474*^9}, 3.894966963649662*^9, 
   3.894967089325943*^9, {3.8967586153018847`*^9, 3.896758618793507*^9}, {
   3.8985229570221663`*^9, 3.89852295756607*^9}, {3.898523009221813*^9, 
   3.898523031804574*^9}, {3.8985868831652193`*^9, 3.898586912982183*^9}, {
   3.898586980307013*^9, 3.898586981896694*^9}, {3.898588083010705*^9, 
   3.898588138147753*^9}, {3.8985882509066477`*^9, 3.898588257861258*^9}, {
   3.898588386465019*^9, 3.8985883874519997`*^9}, 3.898588872783299*^9, {
   3.8986827652733583`*^9, 3.8986827782734623`*^9}, {3.898683960479742*^9, 
   3.898683986130227*^9}, {3.898684016247035*^9, 3.8986840262438383`*^9}, {
   3.898684430172763*^9, 3.898684432084651*^9}, 3.898743696792676*^9, {
   3.898765813939581*^9, 3.898765821419359*^9}, {3.89892598014555*^9, 
   3.89892607627559*^9}, {3.898926107508581*^9, 3.898926159921134*^9}, {
   3.898926262219098*^9, 3.898926264392284*^9}, {3.8989263209124203`*^9, 
   3.898926323493043*^9}, 3.899357129611437*^9, {3.900041005248198*^9, 
   3.900041005452726*^9}, 3.902806726374661*^9, {3.902807429931666*^9, 
   3.902807480980708*^9}, {3.902807561707238*^9, 3.902807599320458*^9}, {
   3.9028080149308147`*^9, 3.902808027680889*^9}, 3.9028194637392273`*^9, {
   3.9030681865729933`*^9, 3.903068263753872*^9}, {3.903068410823492*^9, 
   3.9030684174009953`*^9}, {3.9030685022472258`*^9, 3.903068611921341*^9}, 
   3.903068709752397*^9},
 CellLabel->"In[8]:=",ExpressionUUID->"94dee60f-bc42-4a1e-8b17-64de82078d28"]
}, Closed]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{
   RowBox[{
    RowBox[{"solveModelHelper", "[", 
     RowBox[{
     "inputData_", ",", "ipoints_", ",", "initialDistribution_", ",", 
      "allParms_"}], "]"}], " ", "--"}], " ", "a", " ", "helper", " ", 
   "module", " ", "that", " ", "uses", " ", "SolveModel", " ", "and", " ", 
   "constructs", " ", "the", " ", "point", " ", "inputs", " ", "used", " ", 
   "by", " ", "that", " ", "module"}], " ", "*)"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.},
 CellChangeTimes->{{3.896949669204501*^9, 3.89694967247908*^9}, 
   3.896949825120364*^9, 3.8988298890041027`*^9, {3.898834694786047*^9, 
   3.898834694887288*^9}, 3.899790334428913*^9, {3.902923178192461*^9, 
   3.902923230543974*^9}, {3.9030687549731903`*^9, 3.9030687555696487`*^9}},
 CellLabel->"In[9]:=",ExpressionUUID->"8fe704a3-0299-40a4-a371-3a95e2d3b8a1"],

Cell[BoxData[
 RowBox[{
  RowBox[{
   RowBox[{"solveModelHelper", "[", 
    RowBox[{
    "inputData_", ",", "ipoints_", ",", "initialDistribution_", ",", 
     "allParms_", ",", 
     RowBox[{"evaluatePercentiles_", ":", "0"}]}], "]"}], ":=", 
   RowBox[{"Module", "[", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"points", ",", "ans", ",", "points2"}], "}"}], ",", 
     "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
     "\[IndentingNewLine]", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"points", "=", 
       RowBox[{"{", 
        RowBox[{
         RowBox[{"inityear", "\[Rule]", 
          RowBox[{"(", 
           RowBox[{"inityear", "/.", "allParms"}], ")"}]}], ",", 
         RowBox[{"currentyear", "\[Rule]", 
          RowBox[{"(", 
           RowBox[{"currentyear", "/.", "allParms"}], ")"}]}], ",", 
         RowBox[{"\[Delta]", "\[Rule]", 
          RowBox[{"(", 
           RowBox[{"\[Delta]", "/.", "allParms"}], ")"}]}], ",", 
         RowBox[{"eNdata", "\[Rule]", 
          RowBox[{
           RowBox[{"(", 
            RowBox[{"Nm1parm", "/.", "allParms"}], ")"}], "*", 
           RowBox[{
            RowBox[{"Quiet", "[", 
             RowBox[{"smoothedLevelsFromGrowth", "[", 
              RowBox[{
               RowBox[{"(", 
                RowBox[{"gNCutoffs", "/.", "inputData"}], ")"}], ",", 
               RowBox[{
                RowBox[{"(", 
                 RowBox[{"inityear", "/.", "inputData"}], ")"}], "-", "25"}], 
               ",", 
               RowBox[{
                RowBox[{"(", 
                 RowBox[{"currentyear", "+", "gNyearsFuture"}], ")"}], "/.", 
                "inputData"}]}], "]"}], "]"}], "[", 
            RowBox[{"[", 
             RowBox[{"All", ",", "2"}], "]"}], "]"}]}]}], ",", 
         RowBox[{"gNss", "\[Rule]", 
          RowBox[{"(", 
           RowBox[{"gNss", "/.", "allParms"}], ")"}]}], ",", 
         RowBox[{"Dee", "\[Rule]", 
          RowBox[{
           RowBox[{"Quiet", "[", 
            RowBox[{"smoothedLevelsFromGrowth", "[", 
             RowBox[{
              RowBox[{"(", 
               RowBox[{"gDCutoffs", "/.", "inputData"}], ")"}], ",", 
              RowBox[{
               RowBox[{"(", 
                RowBox[{"inityear", "/.", "inputData"}], ")"}], "-", "25"}], 
              ",", 
              RowBox[{
               RowBox[{"(", 
                RowBox[{"currentyear", "+", "gDyearsFuture"}], ")"}], "/.", 
               "inputData"}]}], "]"}], "]"}], "[", 
           RowBox[{"[", 
            RowBox[{"All", ",", "2"}], "]"}], "]"}]}], ",", 
         RowBox[{"grDee", "\[Rule]", 
          RowBox[{"(", 
           RowBox[{"gDss", "/.", "allParms"}], ")"}]}], ",", 
         RowBox[{"\[Nu]", "\[Rule]", 
          RowBox[{"(", 
           RowBox[{"\[Nu]", "/.", "allParms"}], ")"}]}], ",", 
         RowBox[{"\[Alpha]", "\[Rule]", 
          RowBox[{"(", 
           RowBox[{"\[Alpha]", "/.", "allParms"}], ")"}]}], ",", 
         RowBox[{"Pie", "\[Rule]", 
          RowBox[{"(", 
           RowBox[{"Pie", "/.", "allParms"}], ")"}]}], ",", 
         RowBox[{"Piess", "\[Rule]", 
          RowBox[{"(", 
           RowBox[{"Piess", "/.", "allParms"}], ")"}]}], ",", 
         RowBox[{"\[Omega]", "\[Rule]", 
          RowBox[{"(", 
           RowBox[{"\[Omega]", "/.", "allParms"}], ")"}]}], ",", 
         RowBox[{"time", "\[Rule]", 
          RowBox[{"(", 
           RowBox[{"time", "/.", "allParms"}], ")"}]}], ",", 
         RowBox[{"\[Beta]", "\[Rule]", 
          RowBox[{"initialDistribution", "[", 
           RowBox[{"[", 
            RowBox[{"All", ",", "1"}], "]"}], "]"}]}], ",", 
         RowBox[{"propN", "\[Rule]", 
          RowBox[{"initialDistribution", "[", 
           RowBox[{"[", 
            RowBox[{"All", ",", "2"}], "]"}], "]"}]}], ",", 
         RowBox[{
          SubscriptBox["ktilde", 
           RowBox[{"-", "1"}]], "\[Rule]", 
          SubscriptBox["ktilde", "0"]}], ",", 
         RowBox[{"precision", "\[Rule]", 
          RowBox[{"(", 
           RowBox[{"precision", "/.", "allParms"}], ")"}]}], ",", 
         RowBox[{"percentiles", "\[Rule]", 
          RowBox[{"(", 
           RowBox[{"percentiles", "/.", "allParms"}], ")"}]}]}], "}"}]}], ";",
       "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"points2", "=", 
       RowBox[{"Join", "[", 
        RowBox[{"points", ",", 
         RowBox[{"{", 
          RowBox[{"initpoints", "\[Rule]", "ipoints"}], "}"}]}], "]"}]}], ";",
       "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"ans", "=", 
       RowBox[{"Quiet", "[", 
        RowBox[{"SolveModel", "[", 
         RowBox[{"points2", ",", "evaluatePercentiles"}], "]"}], "]"}]}], ";",
       "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"Return", "[", "ans", "]"}], ";"}]}], "\[IndentingNewLine]", 
    "]"}]}], ";"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.},
 CellChangeTimes->{{3.89694755531358*^9, 3.8969475914112587`*^9}, {
   3.896947624174315*^9, 3.896947634524227*^9}, {3.896948079011478*^9, 
   3.896948090507757*^9}, {3.896948124239146*^9, 3.8969481533701277`*^9}, {
   3.89694826504105*^9, 3.896948287289524*^9}, {3.896949420151319*^9, 
   3.896949420586319*^9}, {3.896949470718544*^9, 3.896949506054953*^9}, {
   3.896949661043169*^9, 3.896949672479826*^9}, 3.896949824249729*^9, {
   3.8969499745875397`*^9, 3.896949974744665*^9}, {3.896950262920906*^9, 
   3.89695027048473*^9}, {3.898829230856596*^9, 3.8988292684478197`*^9}, {
   3.8988297675340767`*^9, 3.898829804356326*^9}, {3.898829943087997*^9, 
   3.8988299475303087`*^9}, {3.898834659625452*^9, 3.898834683896999*^9}, {
   3.9028076538101788`*^9, 3.902807663362838*^9}, {3.902808037295775*^9, 
   3.902808039919017*^9}, 3.9028134542096977`*^9, {3.902813484902444*^9, 
   3.9028134877206507`*^9}, {3.902981145952148*^9, 3.9029811481667843`*^9}, {
   3.902981267329793*^9, 3.902981272061664*^9}},
 CellLabel->"In[10]:=",ExpressionUUID->"d2d9e949-5307-4c13-a17c-ca53cf24cbaa"]
}, Closed]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{"SolveModelFixedCapital", " ", "-", " ", 
   RowBox[{
   "Module", " ", "that", " ", "solves", " ", "model", " ", "with", " ", 
    "fixed", " ", "capital"}]}], " ", "*)"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.},
 CellChangeTimes->{{3.5450253019140635`*^9, 3.545025304915063*^9}, {
   3.5450324742890635`*^9, 3.5450324819140635`*^9}, {3.724479346029998*^9, 
   3.7244794610184035`*^9}, {3.7244795438463507`*^9, 3.724479554254569*^9}, {
   3.7260565353620577`*^9, 3.7260565430614977`*^9}, 3.7260578532684374`*^9, 
   3.726579461512018*^9, {3.726579559728636*^9, 3.726579586301156*^9}, {
   3.7265804157025948`*^9, 3.726580472134823*^9}, {3.726675052388584*^9, 
   3.7266750541206837`*^9}, {3.726736336745963*^9, 3.72673634385637*^9}, {
   3.7267458479639735`*^9, 3.7267458612117314`*^9}, {3.7270949226440563`*^9, 
   3.7270949246821723`*^9}, 3.727096924615328*^9, 3.7271009968402452`*^9, {
   3.7271015671358647`*^9, 3.7271015677228985`*^9}, {3.7610437803591704`*^9, 
   3.7610437849279823`*^9}, {3.7619207454984493`*^9, 3.7619207476240177`*^9}, 
   3.7730639713097205`*^9, {3.776491683018301*^9, 3.7764917078746634`*^9}, 
   3.902889024775201*^9, {3.9029053065384817`*^9, 3.902905333330941*^9}, {
   3.902923240845504*^9, 3.902923246192933*^9}, {3.903068761499569*^9, 
   3.903068764237558*^9}},
 CellLabel->"In[11]:=",ExpressionUUID->"2283dd61-4aca-4e7c-ae08-eeb7a047b714"],

Cell[BoxData[
 RowBox[{
  RowBox[{
   RowBox[{"SolveModelFixedCapital", "[", "parameterVector_", "]"}], ":=", 
   "\[IndentingNewLine]", 
   RowBox[{"Module", "[", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{
       RowBox[{"pVectorAll", "=", "parameterVector"}], ",", "pVector", ",", 
       "\[IndentingNewLine]", "\[Alpha]", ",", "\[Beta]A", ",", "\[Beta]B", 
       ",", "Pie", ",", "Dee", ",", "time", ",", "\[Xi]", ",", "\[Nu]", ",", 
       "\[IndentingNewLine]", "\[IndentingNewLine]", "w", ",", "r", ",", "Ce",
        ",", "LHS", ",", "relcB0", ",", "\[IndentingNewLine]", 
       "\[IndentingNewLine]", "eqs", ",", "eqs1", ",", "eqs2", ",", "eqs3", 
       ",", "eqs4", ",", "eqs5", ",", "\[IndentingNewLine]", 
       "\[IndentingNewLine]", "eq", ",", "eq1", ",", "eq2", ",", "eq3", ",", 
       "eq4", ",", "eq5", ",", "mint", ",", "\[IndentingNewLine]", 
       "\[IndentingNewLine]", "varp", ",", "varN", ",", "varRelcB0", ",", 
       "answerAllNi", ",", "answerAllci", ",", "answerAllKi", ",", 
       "answerAllsi", ",", "answerW", ",", "points", ",", "answerAllYi", ",", 
       "answerY", ",", "relbeta", ",", "\[IndentingNewLine]", 
       "\[IndentingNewLine]", "Nss", ",", "pss", ",", "answerN", ",", 
       "answerp", ",", "answerR", ",", "answerCag", ",", "vars", ",", 
       "answer", ",", " ", "\[Beta]vec", ",", "propNvec", ",", 
       "sorted\[Beta]Location", ",", "nTypes", ",", " ", "acc", ",", "temp", 
       ",", "temp2", ",", "temp3", ",", "tempNp", ",", "helper", ",", 
       "helper2", ",", "helper3", ",", "ci", ",", "Kii", ",", "Nii", ",", 
       "sii", ",", "cij", ",", "Kij", ",", "Nij", ",", "pct", ",", 
       "answerCQuantiles", ",", "answerKQuantiles", ",", "answerNQuantiles", 
       ",", "indexpct", ",", "answerKii", ",", "answerKi", ",", 
       "answerSharesSelectedYears", ",", "answerSocietalBeta", ",", 
       "inityear", ",", "currentyear", ",", "cyperiod"}], "}"}], ",", 
     "\[IndentingNewLine]", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"pVector", "=", 
       RowBox[{"pVectorAll", "[", 
        RowBox[{"[", 
         RowBox[{"All", ",", "2"}], "]"}], "]"}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"inityear", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "1", "]"}], "]"}]}], ";", "\[IndentingNewLine]", 
      RowBox[{"currentyear", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "2", "]"}], "]"}]}], ";", "\[IndentingNewLine]", 
      RowBox[{"cyperiod", "=", 
       FractionBox[
        RowBox[{"currentyear", "-", "inityear"}], "25"]}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{
       SubscriptBox["N", "0"], "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "3", "]"}], "]"}]}], ";", "                  ", 
      RowBox[{"(*", 
       RowBox[{"Total", " ", "Population", " ", "period", " ", "0"}], "*)"}], 
      "\[IndentingNewLine]", 
      RowBox[{
       SubscriptBox["N", "cyperiod"], "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "4", "]"}], "]"}]}], ";", "     ", 
      RowBox[{"(*", 
       RowBox[{"Total", " ", 
        RowBox[{"Land", "/", "Capital"}]}], "*)"}], "\[IndentingNewLine]", 
      RowBox[{"Dee", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "5", "]"}], "]"}]}], ";", "  ", 
      RowBox[{"(*", 
       RowBox[{"Level", " ", "of", " ", "TFP"}], "*)"}], 
      "\[IndentingNewLine]", 
      RowBox[{"\[Nu]", " ", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "6", "]"}], "]"}]}], ";", "   ", 
      RowBox[{"(*", 
       RowBox[{
        RowBox[{"Land", "/", "Capital"}], " ", "Share", " ", "in", " ", 
        "Production", " ", "Function"}], "*)"}], "\[IndentingNewLine]", 
      RowBox[{"\[Alpha]", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "7", "]"}], "]"}]}], ";", "     ", 
      RowBox[{"(*", 
       RowBox[{"Preference", " ", "weight", " ", "on", " ", "consumption"}], 
       "*)"}], "\[IndentingNewLine]", 
      RowBox[{"Pie", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "8", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", 
       RowBox[{
       "Probability", " ", "of", " ", "death", " ", "of", " ", "adults"}], 
       "*)"}], "\[IndentingNewLine]", 
      RowBox[{"time", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "9", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", " ", 
       RowBox[{"The", " ", "time", " ", 
        RowBox[{"periods", "/", "generations"}], " ", "under", " ", 
        RowBox[{"consideration", "."}]}], "*)"}], "\[IndentingNewLine]", 
      RowBox[{"\[Beta]vec", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "10", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", 
       RowBox[{"Reads", " ", "in", " ", "the", " ", "betas"}], "*)"}], 
      "\[IndentingNewLine]", 
      RowBox[{"propNvec", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "11", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", 
       RowBox[{"Reads", " ", "in", " ", "the", " ", "betas"}], "*)"}], 
      "\[IndentingNewLine]", 
      RowBox[{"acc", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "12", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", 
       RowBox[{"Accuracy", "/", "precision"}], "*)"}], "\[IndentingNewLine]", 
      RowBox[{"pct", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "13", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", 
       RowBox[{"Number", " ", "of", " ", "percentiles"}], "*)"}], 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"sorted\[Beta]Location", "=", 
       RowBox[{"Reverse", "[", 
        RowBox[{"Ordering", "[", "\[Beta]vec", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", 
       RowBox[{
       "Returns", " ", "the", " ", "location", " ", "of", " ", "the", " ", 
        "sorted", " ", "betas", " ", "from", " ", "largest", " ", "to", " ", 
        "smallest", " ", "in", " ", "pVector\[Beta]"}], "*)"}], 
      "\[IndentingNewLine]", 
      RowBox[{"nTypes", "=", 
       RowBox[{"Length", "[", "\[Beta]vec", "]"}]}], ";", "  ", 
      RowBox[{"(*", 
       RowBox[{"Number", " ", "of", " ", "different", " ", "types"}], "*)"}], 
      "\[IndentingNewLine]", 
      RowBox[{"For", "[", 
       RowBox[{
        RowBox[{"i", "=", "1"}], ",", 
        RowBox[{"i", "\[LessEqual]", "nTypes"}], ",", 
        RowBox[{"i", "++"}], ",", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"j", "=", 
          RowBox[{"sorted\[Beta]Location", "[", 
           RowBox[{"[", "i", "]"}], "]"}]}], ";", 
         RowBox[{"(*", 
          RowBox[{
          "Find", " ", "the", " ", "location", " ", "of", " ", "the", " ", 
           "sorted", " ", "beta"}], "*)"}], "\[IndentingNewLine]", 
         RowBox[{
          SubscriptBox["\[Beta]", "i"], "=", 
          RowBox[{"\[Beta]vec", "[", 
           RowBox[{"[", "j", "]"}], "]"}]}], ";", " ", 
         RowBox[{"(*", 
          RowBox[{
          "Assigns", " ", "beta", " ", "in", " ", "the", " ", "right", " ", 
           "order"}], "*)"}], "\[IndentingNewLine]", 
         RowBox[{
          SubscriptBox["propN", "i"], "=", 
          RowBox[{"SetPrecision", "[", 
           RowBox[{
            RowBox[{"propNvec", "[", 
             RowBox[{"[", "j", "]"}], "]"}], ",", "acc"}], "]"}]}], ";", " ", 
         RowBox[{"(*", 
          RowBox[{
          "Assigns", " ", "beta", " ", "in", " ", "the", " ", "right", " ", 
           "order"}], "*)"}], "\[IndentingNewLine]", 
         RowBox[{
          SubscriptBox["relN0", "i"], "=", 
          RowBox[{"SetPrecision", "[", 
           RowBox[{
            FractionBox[
             SubscriptBox["propN", "i"], 
             SubscriptBox["propN", "1"]], ",", "acc"}], "]"}]}], ";", " ", 
         RowBox[{"(*", 
          RowBox[{
          "Calculate", " ", "the", " ", "proportions", " ", "of", " ", 
           "people", " ", "in", " ", "each", " ", "type", " ", "relative", 
           " ", "to", " ", "the", " ", "highest", " ", "beta", " ", "type"}], 
          "*)"}], "\[IndentingNewLine]", 
         RowBox[{
          SubscriptBox["relc0", "i"], "=", 
          RowBox[{"SetPrecision", "[", 
           RowBox[{
            RowBox[{
             FractionBox[
              RowBox[{
               SubscriptBox["\[Beta]", "i"], " ", 
               RowBox[{"(", 
                RowBox[{"1", "-", "\[Alpha]", "-", 
                 SubscriptBox["\[Beta]", "1"]}], ")"}]}], 
              RowBox[{
               SubscriptBox["\[Beta]", "1"], " ", 
               RowBox[{"(", 
                RowBox[{"1", "-", "\[Alpha]", "-", 
                 SubscriptBox["\[Beta]", "i"]}], ")"}]}]], 
             SubscriptBox["relN0", "i"]}], ",", "acc"}], "]"}]}], ";"}]}], 
       "  ", 
       RowBox[{"(*", " ", 
        RowBox[{
        "Given", " ", "the", " ", "above", " ", "calculate", " ", "the", " ", 
         "relative", " ", "proportions", " ", "of", " ", "consumption", " ", 
         "of", " ", "each", " ", "type", " ", "relative", " ", "to", " ", 
         "the", " ", "highest", " ", "beta", " ", "type"}], "*)"}], 
       "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
       "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"Nss", "=", 
       RowBox[{
        SuperscriptBox[
         RowBox[{"(", 
          FractionBox[
           RowBox[{"Dee", " ", 
            RowBox[{"(", 
             RowBox[{
              RowBox[{"-", "1"}], "+", 
              SubscriptBox["\[Beta]", "1"], "+", 
              RowBox[{"\[Alpha]", " ", 
               RowBox[{"(", 
                RowBox[{"1", "+", 
                 RowBox[{
                  SubscriptBox["\[Beta]", "1"], " ", 
                  RowBox[{"(", 
                   RowBox[{
                    RowBox[{"-", "1"}], "+", "\[Nu]"}], ")"}]}]}], ")"}]}]}], 
             ")"}]}], 
           RowBox[{
            RowBox[{"(", 
             RowBox[{"1", "+", 
              RowBox[{"Pie", " ", 
               RowBox[{"(", 
                RowBox[{
                 RowBox[{"-", "1"}], "+", "\[Alpha]"}], ")"}]}]}], ")"}], " ", 
            RowBox[{"(", 
             RowBox[{
              RowBox[{"-", "1"}], "+", 
              SubscriptBox["\[Beta]", "1"]}], ")"}]}]], ")"}], 
         FractionBox["1", "\[Nu]"]], "K"}]}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"pss", "=", 
       RowBox[{
        SuperscriptBox["Dee", 
         FractionBox["1", "\[Nu]"]], " ", 
        FractionBox[
         SubscriptBox["\[Beta]", "1"], 
         RowBox[{"1", "-", 
          SubscriptBox["\[Beta]", "1"]}]], " ", 
        SuperscriptBox[
         RowBox[{"(", 
          FractionBox[
           RowBox[{
            RowBox[{"-", "1"}], "+", 
            SubscriptBox["\[Beta]", "1"], "+", 
            RowBox[{"\[Alpha]", " ", 
             RowBox[{"(", 
              RowBox[{"1", "+", 
               RowBox[{
                SubscriptBox["\[Beta]", "1"], " ", 
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{"-", "1"}], "+", "\[Nu]"}], ")"}]}]}], ")"}]}]}], 
           RowBox[{
            RowBox[{"(", 
             RowBox[{"1", "+", 
              RowBox[{"Pie", " ", 
               RowBox[{"(", 
                RowBox[{
                 RowBox[{"-", "1"}], "+", "\[Alpha]"}], ")"}]}]}], ")"}], " ", 
            RowBox[{"(", 
             RowBox[{
              RowBox[{"-", "1"}], "+", 
              SubscriptBox["\[Beta]", "1"]}], ")"}]}]], ")"}], 
         RowBox[{
          RowBox[{"-", "1"}], "+", 
          FractionBox["1", "\[Nu]"]}]], " ", "\[Nu]"}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"w", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"w", "[", "t", "]"}], "=", 
        RowBox[{
         RowBox[{"(", 
          RowBox[{"1", "-", "\[Nu]"}], ")"}], "*", "Dee", "*", 
         SuperscriptBox["K", "\[Nu]"], "*", 
         SuperscriptBox[
          RowBox[{"SetPrecision", "[", 
           RowBox[{
            SubscriptBox["N", "t"], ",", "acc"}], "]"}], 
          RowBox[{"SetPrecision", "[", 
           RowBox[{
            RowBox[{"-", "\[Nu]"}], ",", "100"}], "]"}]]}]}]}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"r", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"r", "[", "t", "]"}], "=", 
        RowBox[{"\[Nu]", "*", "Dee", "*", 
         SuperscriptBox["K", 
          RowBox[{"\[Nu]", "-", "1"}]], "*", 
         SuperscriptBox[
          SubscriptBox["N", "t"], 
          RowBox[{"1", "-", "\[Nu]"}]]}]}]}], ";", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"Ce", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"Ce", "[", "t", "]"}], "=", 
        RowBox[{
         RowBox[{"Dee", "*", 
          SuperscriptBox["K", "\[Nu]"], "*", 
          SuperscriptBox[
           RowBox[{"SetPrecision", "[", 
            RowBox[{
             SubscriptBox["N", "t"], ",", "acc"}], "]"}], 
           RowBox[{"SetPrecision", "[", 
            RowBox[{
             RowBox[{"1", "-", "\[Nu]"}], ",", "100"}], "]"}]]}], "+", 
         RowBox[{"Pie", "*", 
          RowBox[{"SetPrecision", "[", 
           RowBox[{
            SubscriptBox["N", "t"], ",", "acc"}], "]"}]}], "-", 
         RowBox[{"SetPrecision", "[", 
          RowBox[{
           SubscriptBox["N", 
            RowBox[{"t", "+", "1"}]], ",", "acc"}], "]"}]}]}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"relbeta", "[", 
        RowBox[{"t_", ",", "j_"}], "]"}], ":=", 
       RowBox[{
        RowBox[{"relbeta", "[", 
         RowBox[{"t", ",", "j"}], "]"}], "=", 
        RowBox[{"SetPrecision", "[", 
         RowBox[{
          SuperscriptBox[
           RowBox[{"(", 
            RowBox[{"SetPrecision", "[", 
             RowBox[{
              FractionBox[
               SubscriptBox["\[Beta]", "j"], 
               SubscriptBox["\[Beta]", "1"]], ",", "acc"}], "]"}], ")"}], 
           "t"], ",", "acc"}], "]"}]}]}], ";", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"helper", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"helper", "[", "t", "]"}], "=", 
        RowBox[{"(", 
         RowBox[{"1", "+", 
          RowBox[{
           UnderoverscriptBox["\[Sum]", 
            RowBox[{"j", "=", "2"}], "nTypes"], 
           RowBox[{"(", 
            RowBox[{
             SubscriptBox["relN0", "j"], "*", 
             RowBox[{"relbeta", "[", 
              RowBox[{"t", ",", "j"}], "]"}]}], ")"}]}]}], ")"}]}]}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"helper2", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"helper2", "[", "t", "]"}], "=", 
        RowBox[{"(", 
         RowBox[{"1", "+", 
          RowBox[{
           UnderoverscriptBox["\[Sum]", 
            RowBox[{"j", "=", "2"}], "nTypes"], 
           RowBox[{
            SubscriptBox["relc0", "j"], "*", 
            RowBox[{"relbeta", "[", 
             RowBox[{"t", ",", "j"}], "]"}]}]}]}], ")"}]}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"eqs1", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{
         RowBox[{
          SubscriptBox["\[Beta]", "1"], 
          RowBox[{"(", 
           RowBox[{
            SubscriptBox["p", 
             RowBox[{"t", "+", "1"}]], "+", 
            RowBox[{"r", "[", 
             RowBox[{"t", "+", "1"}], "]"}]}], ")"}], 
          FractionBox[
           RowBox[{"helper2", "[", 
            RowBox[{"t", "+", "1"}], "]"}], 
           RowBox[{"helper2", "[", "t", "]"}]], 
          RowBox[{"Ce", "[", "t", "]"}]}], "-", 
         RowBox[{
          RowBox[{"Ce", "[", 
           RowBox[{"t", "+", "1"}], "]"}], "*", 
          SubscriptBox["p", "t"]}]}], "\[Equal]", "0"}]}], ";", 
      RowBox[{
       RowBox[{"eqs2", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{
         RowBox[{"\[Alpha]", " ", 
          SubscriptBox["\[Beta]", "1"], 
          RowBox[{"(", 
           RowBox[{
            RowBox[{"w", "[", 
             RowBox[{"1", "+", "t"}], "]"}], "+", "Pie"}], ")"}], " ", "*", 
          RowBox[{"Ce", "[", "t", "]"}], 
          SubscriptBox["N", 
           RowBox[{"t", "+", "1"}]]}], "+", 
         RowBox[{
          RowBox[{"(", 
           RowBox[{"1", "-", "\[Alpha]", "-", 
            SubscriptBox["\[Beta]", "1"]}], ")"}], 
          FractionBox[
           RowBox[{"helper", "[", 
            RowBox[{"t", "+", "1"}], "]"}], 
           RowBox[{"helper2", "[", 
            RowBox[{"t", "+", "1"}], "]"}]], "*", 
          RowBox[{"Ce", "[", 
           RowBox[{"t", "+", "1"}], "]"}], "*", 
          RowBox[{"Ce", "[", "t", "]"}]}], "-", 
         RowBox[{"\[Alpha]", " ", 
          RowBox[{"Ce", "[", 
           RowBox[{"t", "+", "1"}], "]"}], 
          SubscriptBox["N", 
           RowBox[{"t", "+", "1"}]], "*", 
          FractionBox[
           RowBox[{"helper2", "[", "t", "]"}], 
           RowBox[{"helper2", "[", 
            RowBox[{"t", "+", "1"}], "]"}]]}]}], "\[Equal]", "0"}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       SubscriptBox["N", 
        RowBox[{"time", "+", "1"}]], "=", "Nss"}], ";", "\[IndentingNewLine]",
       "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"answerN", "=", 
       RowBox[{"FindRoot", "[", 
        RowBox[{
         RowBox[{"Table", "[", 
          RowBox[{
           RowBox[{"eqs2", "[", "t", "]"}], ",", 
           RowBox[{"{", 
            RowBox[{"t", ",", 
             RowBox[{"-", "1"}], ",", 
             RowBox[{"time", "-", "1"}]}], "}"}]}], "]"}], ",", 
         RowBox[{"Append", "[", 
          RowBox[{
           RowBox[{"DeleteCases", "[", 
            RowBox[{
             RowBox[{"DeleteCases", "[", 
              RowBox[{
               RowBox[{"Table", "[", 
                RowBox[{
                 RowBox[{"{", 
                  RowBox[{
                   SubscriptBox["N", "i"], ",", "6", ",", "0", ",", "20"}], 
                  "}"}], ",", 
                 RowBox[{"{", 
                  RowBox[{"i", ",", 
                   RowBox[{"-", "1"}], ",", "time"}], "}"}]}], "]"}], ",", 
               RowBox[{"{", 
                RowBox[{
                 SubscriptBox["N", "0"], ",", "6", ",", "0", ",", "20"}], 
                "}"}]}], "]"}], ",", 
             RowBox[{"{", 
              RowBox[{
               SubscriptBox["N", "cyperiod"], ",", "6", ",", "0", ",", "20"}],
               "}"}]}], "]"}], ",", 
           RowBox[{"{", 
            RowBox[{"K", ",", "11.7"}], "}"}]}], "]"}]}], "]"}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"K", "=", 
       RowBox[{"K", "/.", "answerN"}]}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       SubscriptBox["N", 
        RowBox[{"time", "+", "2"}]], "=", "Nss"}], ";", "\[IndentingNewLine]", 
      RowBox[{
       SubscriptBox["p", 
        RowBox[{"time", "+", "1"}]], "=", "pss"}], ";", "\[IndentingNewLine]",
       "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"answerp", "=", 
       RowBox[{"{", "}"}]}], ";", "\[IndentingNewLine]", 
      RowBox[{"For", "[", 
       RowBox[{
        RowBox[{"i", "=", "time"}], ",", 
        RowBox[{"i", "\[GreaterEqual]", 
         RowBox[{"-", "1"}]}], ",", 
        RowBox[{"i", "--"}], ",", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"temp", "=", 
          RowBox[{"Join", "[", 
           RowBox[{"answerp", ",", "answerN"}], "]"}]}], ";", 
         "\[IndentingNewLine]", 
         RowBox[{"answerp", "=", 
          RowBox[{"Join", "[", 
           RowBox[{
            RowBox[{
             RowBox[{"Solve", "[", 
              RowBox[{
               RowBox[{
                RowBox[{"eqs1", "[", "i", "]"}], "/.", "temp"}], ",", 
               SubscriptBox["p", "i"]}], "]"}], "[", 
             RowBox[{"[", "1", "]"}], "]"}], ",", "answerp"}], "]"}]}], 
         ";"}]}], "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"tempNp", "=", 
       RowBox[{"Join", "[", 
        RowBox[{"answerN", ",", "answerp"}], "]"}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"Nii", "[", 
        RowBox[{"i_", ",", "t_"}], "]"}], ":=", 
       RowBox[{
        RowBox[{"Nii", "[", 
         RowBox[{"i", ",", "t"}], "]"}], "=", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"t", "\[LessEqual]", "time"}], ",", 
          RowBox[{
           FractionBox[
            RowBox[{
             SubscriptBox["relN0", "i"], "*", 
             RowBox[{"relbeta", "[", 
              RowBox[{"t", ",", "i"}], "]"}]}], 
            RowBox[{"helper", "[", "t", "]"}]], "*", 
           SubscriptBox["N", "t"]}], ",", 
          RowBox[{"If", "[", 
           RowBox[{
            RowBox[{"i", "\[Equal]", "1"}], ",", "Nss", ",", "0"}], "]"}]}], 
         "]"}]}]}], ";", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"ci", "[", 
        RowBox[{"i_", ",", "t_"}], "]"}], ":=", 
       RowBox[{
        RowBox[{"ci", "[", 
         RowBox[{"i", ",", "t"}], "]"}], "=", 
        RowBox[{
         FractionBox[
          RowBox[{
           SubscriptBox["relc0", "i"], "*", 
           RowBox[{"relbeta", "[", 
            RowBox[{"t", ",", "i"}], "]"}]}], 
          RowBox[{"helper2", "[", "t", "]"}]], "*", 
         RowBox[{"Ce", "[", "t", "]"}]}]}]}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"sii", "[", 
        RowBox[{"i_", ",", "t_"}], "]"}], ":=", 
       RowBox[{
        RowBox[{"sii", "[", 
         RowBox[{"i", ",", "t"}], "]"}], "=", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"t", "\[LessEqual]", "time"}], ",", 
          RowBox[{
           RowBox[{"(", 
            FractionBox[
             RowBox[{
              RowBox[{"Nii", "[", 
               RowBox[{"i", ",", 
                RowBox[{"t", "+", "1"}]}], "]"}], "-", 
              RowBox[{"Pie", " ", 
               RowBox[{"Nii", "[", 
                RowBox[{"i", ",", "t"}], "]"}]}]}], 
             RowBox[{
              RowBox[{"Nii", "[", 
               RowBox[{"i", ",", 
                RowBox[{"t", "+", "1"}]}], "]"}], "-", 
              RowBox[{"Pie", " ", 
               RowBox[{"Nii", "[", 
                RowBox[{"i", ",", "t"}], "]"}]}], "+", 
              RowBox[{"ci", "[", 
               RowBox[{"i", ",", "t"}], "]"}]}]], ")"}], "/.", "tempNp"}], 
          ",", 
          RowBox[{"If", "[", 
           RowBox[{
            RowBox[{"i", "\[Equal]", "1"}], ",", 
            FractionBox[
             RowBox[{
              RowBox[{"(", 
               RowBox[{"1", "-", "Pie"}], ")"}], " ", 
              RowBox[{"(", 
               RowBox[{"1", "-", "\[Alpha]", "-", 
                RowBox[{
                 RowBox[{"(", 
                  RowBox[{"1", "-", 
                   RowBox[{"\[Alpha]", " ", 
                    RowBox[{"(", 
                    RowBox[{"1", "-", "\[Nu]"}], ")"}]}]}], ")"}], " ", 
                 SubscriptBox["\[Beta]", "1"]}]}], ")"}]}], 
             RowBox[{
              RowBox[{"(", 
               RowBox[{"1", "+", 
                RowBox[{"Pie", " ", 
                 RowBox[{"(", 
                  RowBox[{
                   RowBox[{"-", "1"}], "+", "\[Alpha]"}], ")"}]}]}], ")"}], 
              " ", 
              RowBox[{"(", 
               RowBox[{"1", "-", 
                SubscriptBox["\[Beta]", "1"]}], ")"}]}]], ",", "0"}], "]"}]}],
          "]"}]}]}], ";", " ", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"(*", 
       RowBox[{
        RowBox[{"answerKii", "=", 
         RowBox[{"{", "}"}]}], ";", "\[IndentingNewLine]", 
        RowBox[{"For", "[", 
         RowBox[{
          RowBox[{"i", "=", "1"}], ",", 
          RowBox[{"i", "\[LessEqual]", "nTypes"}], ",", 
          RowBox[{"i", "++"}], ",", "\[IndentingNewLine]", 
          RowBox[{
           RowBox[{"answerKi", "=", 
            RowBox[{"{", "}"}]}], ";", "\[IndentingNewLine]", 
           RowBox[{"For", "[", 
            RowBox[{
             RowBox[{"t", "=", "time"}], ",", 
             RowBox[{"t", "\[GreaterEqual]", "0"}], ",", 
             RowBox[{"t", "--"}], ",", "\[IndentingNewLine]", 
             RowBox[{
              RowBox[{"temp", "=", 
               RowBox[{"Join", "[", 
                RowBox[{"answerKi", ",", "answerN"}], "]"}]}], ";", 
              "\[IndentingNewLine]", 
              RowBox[{"answerKi", "=", 
               RowBox[{"Join", "[", 
                RowBox[{
                 RowBox[{
                  RowBox[{"Solve", "[", 
                   RowBox[{
                    RowBox[{
                    RowBox[{"eqs3", "[", 
                    RowBox[{"i", ",", "t"}], "]"}], "/.", "temp"}], ",", 
                    SubscriptBox["Ki", 
                    RowBox[{"i", ",", "t"}]]}], "]"}], "[", 
                  RowBox[{"[", "1", "]"}], "]"}], ",", "answerKi"}], "]"}]}], 
              ";"}]}], "\[IndentingNewLine]", "]"}], ";", 
           "\[IndentingNewLine]", 
           RowBox[{"answerKii", "=", 
            RowBox[{"Join", "[", 
             RowBox[{"answerKii", ",", 
              RowBox[{"{", "answerKi", "}"}]}], "]"}]}], ";"}]}], 
         "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"Kii", "[", 
          RowBox[{"i_", ",", "t_"}], "]"}], ":=", 
         RowBox[{
          RowBox[{"Kii", "[", 
           RowBox[{"i", ",", "t"}], "]"}], "=", 
          RowBox[{"answerKii", "[", 
           RowBox[{"[", 
            RowBox[{"i", ",", 
             RowBox[{"t", "+", "1"}], ",", "2"}], "]"}], "]"}]}]}], ";"}], 
       "\[IndentingNewLine]", "*)"}], "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"(*", 
       RowBox[{
        RowBox[{
         RowBox[{"Kij", "[", 
          RowBox[{"i_", ",", "j_"}], "]"}], ":=", 
         RowBox[{"Table", "[", 
          RowBox[{
           RowBox[{"(", 
            RowBox[{
             UnderoverscriptBox["\[Sum]", 
              RowBox[{"k", "=", "i"}], "j"], 
             RowBox[{"Kii", "[", 
              RowBox[{"k", ",", "t"}], "]"}]}], ")"}], ",", 
           RowBox[{"{", 
            RowBox[{"t", ",", "0", ",", "time"}], "}"}]}], "]"}]}], ";", 
        "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"Nij", "[", 
          RowBox[{"i_", ",", "j_"}], "]"}], ":=", 
         RowBox[{"Table", "[", 
          RowBox[{
           RowBox[{"(", 
            RowBox[{
             UnderoverscriptBox["\[Sum]", 
              RowBox[{"k", "=", "i"}], "j"], 
             RowBox[{"Nii", "[", 
              RowBox[{"k", ",", "t"}], "]"}]}], ")"}], ",", 
           RowBox[{"{", 
            RowBox[{"t", ",", "0", ",", "time"}], "}"}]}], "]"}]}], ";"}], 
       "*)"}], "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"indexpct", "=", 
       RowBox[{"Join", "[", 
        RowBox[{
         RowBox[{"{", "0", "}"}], ",", 
         RowBox[{"Quantile", "[", 
          RowBox[{
           RowBox[{"Table", "[", 
            RowBox[{"i", ",", 
             RowBox[{"{", 
              RowBox[{"i", ",", "1", ",", "nTypes"}], "}"}]}], "]"}], ",", 
           RowBox[{"Table", "[", 
            RowBox[{
             FractionBox["i", "pct"], ",", 
             RowBox[{"{", 
              RowBox[{"i", ",", "1", ",", "pct"}], "}"}]}], "]"}]}], "]"}]}], 
        "]"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"cij", "[", 
        RowBox[{"i_", ",", "j_"}], "]"}], ":=", 
       RowBox[{"Table", "[", 
        RowBox[{
         RowBox[{
          SubscriptBox[
           RowBox[{"ToExpression", "[", 
            RowBox[{"(", 
             RowBox[{"\"\<CQ\>\"", "<>", 
              RowBox[{"ToString", "[", "\[IndentingNewLine]", 
               RowBox[{"(", 
                RowBox[{
                 RowBox[{"Position", "[", 
                  RowBox[{"indexpct", ",", 
                   RowBox[{"i", "-", "1"}]}], "]"}], "[", 
                 RowBox[{"[", 
                  RowBox[{"1", ",", "1"}], "]"}], "]"}], ")"}], "]"}]}], 
             ")"}], "]"}], "t"], "\[Rule]", 
          RowBox[{"(", 
           RowBox[{
            UnderoverscriptBox["\[Sum]", 
             RowBox[{"k", "=", "i"}], "j"], 
            RowBox[{"ci", "[", 
             RowBox[{"k", ",", "t"}], "]"}]}], ")"}]}], ",", 
         RowBox[{"{", 
          RowBox[{"t", ",", "0", ",", "time"}], "}"}]}], "]"}]}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"Nij", "[", 
        RowBox[{"i_", ",", "j_"}], "]"}], ":=", 
       RowBox[{"Table", "[", 
        RowBox[{
         RowBox[{
          SubscriptBox[
           RowBox[{"ToExpression", "[", 
            RowBox[{"(", 
             RowBox[{"\"\<NQ\>\"", "<>", 
              RowBox[{"ToString", "[", "\[IndentingNewLine]", 
               RowBox[{"(", 
                RowBox[{
                 RowBox[{"Position", "[", 
                  RowBox[{"indexpct", ",", 
                   RowBox[{"i", "-", "1"}]}], "]"}], "[", 
                 RowBox[{"[", 
                  RowBox[{"1", ",", "1"}], "]"}], "]"}], ")"}], "]"}]}], 
             ")"}], "]"}], "t"], "\[Rule]", 
          RowBox[{"(", 
           FractionBox[
            RowBox[{
             UnderoverscriptBox["\[Sum]", 
              RowBox[{"k", "=", "i"}], "j"], 
             RowBox[{"Nii", "[", 
              RowBox[{"k", ",", "t"}], "]"}]}], 
            SubscriptBox["N", "t"]], ")"}]}], ",", 
         RowBox[{"{", 
          RowBox[{"t", ",", "0", ",", "time"}], "}"}]}], "]"}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"Kij", "[", 
        RowBox[{"i_", ",", "j_"}], "]"}], ":=", 
       RowBox[{"Table", "[", 
        RowBox[{
         RowBox[{
          SubscriptBox[
           RowBox[{"ToExpression", "[", 
            RowBox[{"(", 
             RowBox[{"\"\<KQ\>\"", "<>", 
              RowBox[{"ToString", "[", "\[IndentingNewLine]", 
               RowBox[{"(", 
                RowBox[{
                 RowBox[{"Position", "[", 
                  RowBox[{"indexpct", ",", 
                   RowBox[{"i", "-", "1"}]}], "]"}], "[", 
                 RowBox[{"[", 
                  RowBox[{"1", ",", "1"}], "]"}], "]"}], ")"}], "]"}]}], 
             ")"}], "]"}], "t"], "\[Rule]", 
          RowBox[{"(", 
           RowBox[{
            UnderoverscriptBox["\[Sum]", 
             RowBox[{"k", "=", "i"}], "j"], 
            RowBox[{"Kii", "[", 
             RowBox[{"k", ",", "t"}], "]"}]}], ")"}]}], ",", 
         RowBox[{"{", 
          RowBox[{"t", ",", "0", ",", "time"}], "}"}]}], "]"}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"(*", "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"answerCQuantiles", "=", 
         RowBox[{
          RowBox[{"Table", "[", 
           RowBox[{
            RowBox[{"cij", "[", 
             RowBox[{
              RowBox[{
               RowBox[{"indexpct", "[", 
                RowBox[{"[", "i", "]"}], "]"}], "+", "1"}], ",", 
              RowBox[{"indexpct", "[", 
               RowBox[{"[", 
                RowBox[{"i", "+", "1"}], "]"}], "]"}]}], "]"}], ",", 
            RowBox[{"{", 
             RowBox[{"i", ",", "1", ",", "pct"}], "}"}]}], "]"}], "/.", 
          "answerN"}]}], ";", "\[IndentingNewLine]", 
        RowBox[{"answerNQuantiles", "=", 
         RowBox[{
          RowBox[{"Table", "[", 
           RowBox[{
            RowBox[{"Nij", "[", 
             RowBox[{
              RowBox[{
               RowBox[{"indexpct", "[", 
                RowBox[{"[", "i", "]"}], "]"}], "+", "1"}], ",", 
              RowBox[{"indexpct", "[", 
               RowBox[{"[", 
                RowBox[{"i", "+", "1"}], "]"}], "]"}]}], "]"}], ",", 
            RowBox[{"{", 
             RowBox[{"i", ",", "1", ",", "pct"}], "}"}]}], "]"}], "/.", 
          "answerN"}]}], ";", "\[IndentingNewLine]", 
        RowBox[{"answerKQuantiles", "=", 
         RowBox[{"Table", "[", 
          RowBox[{
           RowBox[{"Kij", "[", 
            RowBox[{
             RowBox[{
              RowBox[{"indexpct", "[", 
               RowBox[{"[", "i", "]"}], "]"}], "+", "1"}], ",", 
             RowBox[{"indexpct", "[", 
              RowBox[{"[", 
               RowBox[{"i", "+", "1"}], "]"}], "]"}]}], "]"}], ",", 
           RowBox[{"{", 
            RowBox[{"i", ",", "1", ",", "pct"}], "}"}]}], "]"}]}], ";"}], 
       "\[IndentingNewLine]", "*)"}], "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"(*", 
       RowBox[{
       "The", " ", "below", " ", "can", " ", "be", " ", "used", " ", "to", 
        " ", "calculate", " ", "shares", " ", "of", " ", "population", " ", 
        "in", " ", "selected", " ", 
        RowBox[{"years", ".", " ", "However"}], " ", "it", " ", "is", " ", 
        "faster", " ", "and", " ", "simplier", " ", "to", " ", "use", " ", 
        "the", " ", "implied", " ", "share", " ", "formulas", " ", "in", " ", 
        "the", " ", 
        RowBox[{"paper", ".", " ", "This"}], " ", "is", " ", "done", " ", 
        "when", " ", "exporting", " ", "the", " ", 
        RowBox[{"data", "."}]}], "*)"}], "\[IndentingNewLine]", 
      RowBox[{"(*", 
       RowBox[{
        RowBox[{"answerSharesSelectedYears", "=", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"Table", "[", 
            RowBox[{
             RowBox[{
              RowBox[{"Nii", "[", 
               RowBox[{"k", ",", "0"}], "]"}], "/.", "answerN"}], ",", 
             RowBox[{"{", 
              RowBox[{"k", ",", "1", ",", "nTypes"}], "}"}]}], "]"}], ",", 
           RowBox[{"Table", "[", 
            RowBox[{
             RowBox[{
              RowBox[{"Nii", "[", 
               RowBox[{"k", ",", "6"}], "]"}], "/.", "answerN"}], ",", 
             RowBox[{"{", 
              RowBox[{"k", ",", "1", ",", "nTypes"}], "}"}]}], "]"}], ",", 
           RowBox[{"Table", "[", 
            RowBox[{
             RowBox[{
              RowBox[{"Nii", "[", 
               RowBox[{"k", ",", "12"}], "]"}], "/.", "answerN"}], ",", 
             RowBox[{"{", 
              RowBox[{"k", ",", "1", ",", "nTypes"}], "}"}]}], "]"}], ",", 
           RowBox[{"Table", "[", 
            RowBox[{
             RowBox[{
              RowBox[{"Nii", "[", 
               RowBox[{"k", ",", "18"}], "]"}], "/.", "answerN"}], ",", 
             RowBox[{"{", 
              RowBox[{"k", ",", "1", ",", "nTypes"}], "}"}]}], "]"}], ",", 
           RowBox[{"Table", "[", 
            RowBox[{
             RowBox[{
              RowBox[{"Nii", "[", 
               RowBox[{"k", ",", "24"}], "]"}], "/.", "answerN"}], ",", 
             RowBox[{"{", 
              RowBox[{"k", ",", "1", ",", "nTypes"}], "}"}]}], "]"}], ",", 
           RowBox[{"Table", "[", 
            RowBox[{
             RowBox[{
              RowBox[{"Nii", "[", 
               RowBox[{"k", ",", "28"}], "]"}], "/.", "answerN"}], ",", 
             RowBox[{"{", 
              RowBox[{"k", ",", "1", ",", "nTypes"}], "}"}]}], "]"}], ",", 
           RowBox[{"Table", "[", 
            RowBox[{
             RowBox[{
              RowBox[{"Nii", "[", 
               RowBox[{"k", ",", "30"}], "]"}], "/.", "answerN"}], ",", 
             RowBox[{"{", 
              RowBox[{"k", ",", "1", ",", "nTypes"}], "}"}]}], "]"}]}], 
          "}"}]}], ";"}], "*)"}], "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"(*", 
       RowBox[{
        RowBox[{
        "The", " ", "below", " ", "can", " ", "be", " ", "used", " ", "to", 
         " ", "calculate", " ", "societal", " ", "discount", " ", 
         RowBox[{"factors", ".", " ", "However"}]}], ",", " ", 
        RowBox[{
        "it", " ", "is", " ", "faster", " ", "and", " ", "simplier", " ", 
         "to", " ", "use", " ", "the", " ", "implied", " ", "mean", " ", 
         "beta", " ", "formula", " ", "in", " ", "the", " ", "paper"}]}], 
       "*)"}], "\[IndentingNewLine]", 
      RowBox[{"(*", 
       RowBox[{
        RowBox[{"answerSocietalBeta", "=", 
         RowBox[{"Table", "[", 
          RowBox[{
           RowBox[{
            FractionBox[
             RowBox[{
              UnderoverscriptBox["\[Sum]", 
               RowBox[{"k", "=", "1"}], "nTypes"], 
              RowBox[{
               RowBox[{"Nii", "[", 
                RowBox[{"k", ",", "t"}], "]"}], "*", 
               SubscriptBox["\[Beta]", "k"]}]}], 
             SubscriptBox["N", "t"]], "/.", "answerN"}], ",", 
           RowBox[{"{", 
            RowBox[{"t", ",", "0", ",", "time"}], "}"}]}], "]"}]}], ";"}], 
       "*)"}], "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"(*", "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"For", "[", 
         RowBox[{
          RowBox[{"i", "=", "1"}], ",", 
          RowBox[{"i", "\[LessEqual]", "nTypes"}], ",", 
          RowBox[{"i", "++"}], ",", "\[IndentingNewLine]", 
          RowBox[{
           RowBox[{
            SubscriptBox["answerNi", "i"], "=", 
            RowBox[{
             RowBox[{"Table", "[", 
              RowBox[{
               RowBox[{
                SubscriptBox["Ni", 
                 RowBox[{"i", ",", "t"}]], "\[Rule]", 
                RowBox[{"Nii", "[", 
                 RowBox[{"i", ",", "t"}], "]"}]}], ",", 
               RowBox[{"{", 
                RowBox[{"t", ",", "0", ",", "time"}], "}"}]}], "]"}], "/.", 
             "answerN"}]}], ";"}]}], "\[IndentingNewLine]", 
         RowBox[{"(*", 
          RowBox[{
           RowBox[{
            SubscriptBox["answerKi", "i"], "=", 
            RowBox[{"Table", "[", 
             RowBox[{
              RowBox[{
               SubscriptBox["Ki", 
                RowBox[{"i", ",", "t"}]], "\[Rule]", 
               RowBox[{"Kii", "[", 
                RowBox[{"i", ",", "t"}], "]"}]}], ",", 
              RowBox[{"{", 
               RowBox[{"t", ",", "0", ",", "time"}], "}"}]}], "]"}]}], ";", 
           "\[IndentingNewLine]", "\[IndentingNewLine]", 
           RowBox[{
            SubscriptBox["answersi", "i"], "=", 
            RowBox[{
             RowBox[{"Table", "[", 
              RowBox[{
               RowBox[{
                SubscriptBox["si", 
                 RowBox[{"i", ",", "t"}]], "\[Rule]", 
                RowBox[{"sii", "[", 
                 RowBox[{"i", ",", "t"}], "]"}]}], ",", 
               RowBox[{"{", 
                RowBox[{"t", ",", "0", ",", 
                 RowBox[{"time", "+", "1"}]}], "}"}]}], "]"}], "/.", 
             "answerN"}]}], ";", "\[IndentingNewLine]", 
           RowBox[{
            SubscriptBox["answerci", "i"], "=", 
            RowBox[{
             RowBox[{"Table", "[", 
              RowBox[{
               RowBox[{
                SubscriptBox["ci", 
                 RowBox[{"i", ",", "t"}]], "\[Rule]", 
                RowBox[{"ci", "[", 
                 RowBox[{"i", ",", "t"}], "]"}]}], ",", 
               RowBox[{"{", 
                RowBox[{"t", ",", "0", ",", 
                 RowBox[{"time", "+", "1"}]}], "}"}]}], "]"}], "/.", 
             "answerN"}]}], ";"}], "*)"}], "\[IndentingNewLine]", "]"}], 
        ";"}], "\[IndentingNewLine]", "*)"}], "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"answerR", "=", 
       RowBox[{
        RowBox[{"Table", "[", 
         RowBox[{
          RowBox[{
           SubscriptBox["R", 
            RowBox[{"t", "+", "1"}]], "\[Rule]", 
           FractionBox[
            RowBox[{
             SubscriptBox["p", 
              RowBox[{"t", "+", "1"}]], "+", 
             RowBox[{"r", "[", 
              RowBox[{"t", "+", "1"}], "]"}]}], 
            SubscriptBox["p", "t"]]}], ",", 
          RowBox[{"{", 
           RowBox[{"t", ",", 
            RowBox[{"-", "1"}], ",", "time"}], "}"}]}], "]"}], "/.", 
        "tempNp"}]}], ";", "\[IndentingNewLine]", 
      RowBox[{"answerCag", "=", 
       RowBox[{
        RowBox[{"Table", "[", 
         RowBox[{
          RowBox[{
           SubscriptBox["Cag", "t"], "\[Rule]", 
           RowBox[{"Ce", "[", "t", "]"}]}], ",", 
          RowBox[{"{", 
           RowBox[{"t", ",", "0", ",", "time"}], "}"}]}], "]"}], "/.", 
        "tempNp"}]}], ";", "\[IndentingNewLine]", 
      RowBox[{"(*", "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"answerAllNi", "=", 
         RowBox[{"{", "}"}]}], ";", "\[IndentingNewLine]", 
        RowBox[{"answerAllKi", "=", 
         RowBox[{"{", "}"}]}], ";", "\[IndentingNewLine]", 
        RowBox[{"answerAllsi", "=", 
         RowBox[{"{", "}"}]}], ";", "\[IndentingNewLine]", 
        "\[IndentingNewLine]", 
        RowBox[{"For", "[", 
         RowBox[{
          RowBox[{"i", "=", "1"}], ",", 
          RowBox[{"i", "\[LessEqual]", "nTypes"}], ",", 
          RowBox[{"i", "++"}], ",", "\[IndentingNewLine]", 
          RowBox[{
           RowBox[{"answerAllNi", "=", 
            RowBox[{"Join", "[", 
             RowBox[{
              RowBox[{"{", 
               SubscriptBox["answerNi", "i"], "}"}], ",", "answerAllNi"}], 
             "]"}]}], ";"}]}], "\[IndentingNewLine]", 
         RowBox[{"(*", 
          RowBox[{
           RowBox[{"answerAllKi", "=", 
            RowBox[{"Join", "[", 
             RowBox[{
              RowBox[{"{", 
               SubscriptBox["answerKi", "i"], "}"}], ",", "answerAllKi"}], 
             "]"}]}], ";", "\[IndentingNewLine]", 
           RowBox[{"answerAllsi", "=", 
            RowBox[{"Join", "[", 
             RowBox[{
              RowBox[{"{", 
               SubscriptBox["answersi", "i"], "}"}], ",", "answerAllsi"}], 
             "]"}]}], ";"}], "*)"}], "\[IndentingNewLine]", "]"}], ";"}], 
       "\[IndentingNewLine]", "\[IndentingNewLine]", "*)"}], 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"temp", "=", 
       SubscriptBox["N", "0"]}], ";", "\[IndentingNewLine]", 
      RowBox[{
       SubscriptBox["N", "0"], "=."}], ";", "\[IndentingNewLine]", 
      RowBox[{"temp2", "=", 
       SubscriptBox["N", "cyperiod"]}], ";", "\[IndentingNewLine]", 
      RowBox[{
       SubscriptBox["N", "cyperiod"], "=."}], ";", "\[IndentingNewLine]", 
      RowBox[{"temp3", "=", "K"}], ";", "\[IndentingNewLine]", 
      RowBox[{"Clear", "[", "K", "]"}], ";", "\[IndentingNewLine]", 
      RowBox[{"answer", "=", 
       RowBox[{"Join", "[", 
        RowBox[{
         RowBox[{"{", 
          RowBox[{"Append", "[", 
           RowBox[{
            RowBox[{"Insert", "[", 
             RowBox[{
              RowBox[{"Prepend", "[", 
               RowBox[{
                RowBox[{"Drop", "[", 
                 RowBox[{"answerN", ",", 
                  RowBox[{"-", "1"}]}], "]"}], ",", 
                RowBox[{
                 SubscriptBox["N", "0"], "\[Rule]", "temp"}]}], "]"}], ",", 
              RowBox[{
               SubscriptBox["N", "cyperiod"], "\[Rule]", "temp2"}], ",", 
              RowBox[{"cyperiod", "+", "1"}]}], "]"}], ",", 
            RowBox[{"K", "\[Rule]", " ", "temp3"}]}], "]"}], "}"}], ",", 
         RowBox[{"{", "answerR", "}"}], ",", 
         RowBox[{"{", "answerp", "}"}], ",", 
         RowBox[{"{", "answerCag", "}"}]}], "]"}]}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{"(*", 
       RowBox[{
        RowBox[{"{", "answerAllNi", "}"}], ",", 
        RowBox[{"{", "answerAllKi", "}"}], ",", 
        RowBox[{"{", "answerAllsi", "}"}], ","}], "*)"}], 
      "\[IndentingNewLine]", 
      RowBox[{"(*", 
       RowBox[{"Clear", " ", "Values"}], "*)"}], "\[IndentingNewLine]", 
      RowBox[{"For", "[", 
       RowBox[{
        RowBox[{"i", "=", "1"}], ",", 
        RowBox[{"i", "\[LessEqual]", "nTypes"}], ",", 
        RowBox[{"i", "++"}], ",", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{
          SubscriptBox["relN0", "i"], "=."}], ";", 
         RowBox[{
          SubscriptBox["propN", "i"], "=."}], ";", 
         RowBox[{
          SubscriptBox["\[Beta]", "i"], "=."}], ";", 
         RowBox[{
          SubscriptBox["relc0", "i"], "=."}], ";"}]}], "\[IndentingNewLine]", 
       RowBox[{"(*", 
        RowBox[{
         RowBox[{
          RowBox[{
           RowBox[{
            RowBox[{
             SubscriptBox["Ki", 
              RowBox[{"i", ",", 
               RowBox[{"time", "+", "1"}]}]], "=."}], ";", 
            "\[IndentingNewLine]", 
            RowBox[{
             SubscriptBox["Ni", 
              RowBox[{"i", ",", 
               RowBox[{"time", "+", "1"}]}]], "=."}], ";"}], "..."}], "..."}],
          ".."}], "*)"}], "\[IndentingNewLine]", "]"}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{
       SubscriptBox["p", 
        RowBox[{"time", "+", "1"}]], "=."}], ";", 
      RowBox[{
       SubscriptBox["N", 
        RowBox[{"time", "+", "1"}]], "=."}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"Return", "[", "answer", "]"}], ";"}]}], "\[IndentingNewLine]", 
    "]"}]}], ";"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.},
 CellChangeTimes->{{3.5450207567370634`*^9, 3.5450208126640635`*^9}, {
   3.5450213922850633`*^9, 3.545021455795063*^9}, {3.545021499609063*^9, 
   3.5450218859630632`*^9}, {3.545022337398063*^9, 3.545022363188063*^9}, {
   3.545022412753063*^9, 3.545022418451063*^9}, {3.545022458470063*^9, 
   3.545022462352063*^9}, {3.5450226095130634`*^9, 3.5450226831710634`*^9}, {
   3.5450227685530634`*^9, 3.545022796658063*^9}, {3.5450231576000633`*^9, 
   3.545023168904063*^9}, 3.545023328852063*^9, {3.5450235965720634`*^9, 
   3.545023615297063*^9}, 3.545023671896063*^9, 3.545025304915063*^9, {
   3.5452319574236*^9, 3.5452319810069494`*^9}, 3.5452320377051926`*^9, 
   3.5452324327457876`*^9, {3.546864863835182*^9, 3.546864899611182*^9}, 
   3.546864971144182*^9, {3.5468650373641825`*^9, 3.5468650609311824`*^9}, {
   3.546866633771182*^9, 3.5468666428381824`*^9}, {3.5468666796221824`*^9, 
   3.5468666868411827`*^9}, {3.5469414861762*^9, 3.5469414947692003`*^9}, 
   3.5471129347887774`*^9, {3.547113040450777*^9, 3.547113044292777*^9}, 
   3.5471181898287773`*^9, {3.547118969707777*^9, 3.547118976816777*^9}, {
   3.5471212301287775`*^9, 3.547121236237777*^9}, {3.547122382551777*^9, 
   3.547122390632777*^9}, {3.547127642744777*^9, 3.547127646376777*^9}, 
   3.5471281319847775`*^9, {3.547132407191777*^9, 3.547132413044777*^9}, {
   3.547133054195777*^9, 3.547133091931777*^9}, {3.547137681165777*^9, 
   3.5471376947607775`*^9}, 3.547137748890777*^9, {3.7244196368117094`*^9, 
   3.7244196690585537`*^9}, {3.7244199852736397`*^9, 3.72442000432973*^9}, 
   3.7244200575997767`*^9, {3.7244202517508817`*^9, 3.7244202524669228`*^9}, {
   3.7244202983375463`*^9, 3.7244202987585707`*^9}, {3.724422768788848*^9, 
   3.724422780798535*^9}, {3.724423196621319*^9, 3.7244232028736763`*^9}, {
   3.7244235236850257`*^9, 3.724423541280032*^9}, {3.724423603039564*^9, 
   3.724423603252577*^9}, {3.72442401819231*^9, 3.7244240721423955`*^9}, {
   3.724425328541513*^9, 3.72442533083232*^9}, {3.724479631636307*^9, 
   3.7244799070073957`*^9}, {3.7244800117084045`*^9, 3.724480165149476*^9}, {
   3.724480222995779*^9, 3.7244802376004047`*^9}, {3.724480279496479*^9, 
   3.724480318614748*^9}, {3.724480412895115*^9, 3.7244804508971825`*^9}, {
   3.7244804896596518`*^9, 3.7244805495495577`*^9}, {3.7244805910118313`*^9, 
   3.724480611153466*^9}, {3.724480755982724*^9, 3.7244807590715294`*^9}, {
   3.7244808686808624`*^9, 3.7244808847459183`*^9}, {3.724480916247033*^9, 
   3.7244809360271125`*^9}, {3.724480976263264*^9, 3.724480994060331*^9}, {
   3.7244810560325747`*^9, 3.724481194781082*^9}, {3.7244812255951834`*^9, 
   3.7244813092584925`*^9}, 3.724482642624999*^9, {3.724499784183713*^9, 
   3.7244997889219847`*^9}, {3.724499898947277*^9, 3.7244999067877254`*^9}, {
   3.724500319348323*^9, 3.72450032175146*^9}, {3.724580135076105*^9, 
   3.7245801734072976`*^9}, {3.7259716811998024`*^9, 
   3.7259717026180277`*^9}, {3.7259718195847178`*^9, 3.725971881274246*^9}, {
   3.7259720133337994`*^9, 3.7259720446285896`*^9}, {3.7259728538058715`*^9, 
   3.72597285464992*^9}, {3.725973025874714*^9, 3.725973038702447*^9}, {
   3.7259732006057076`*^9, 3.7259732305034175`*^9}, {3.7259734422325277`*^9, 
   3.725973443425596*^9}, {3.7259736826442785`*^9, 3.725973712402981*^9}, 
   3.725974082252135*^9, {3.725974168099045*^9, 3.725974171697251*^9}, {
   3.725974276747259*^9, 3.7259743103661823`*^9}, {3.725974496668838*^9, 
   3.725974498521944*^9}, 3.7259748561053967`*^9, {3.725975127455917*^9, 
   3.7259751291570144`*^9}, {3.725975210171648*^9, 3.7259752119847517`*^9}, {
   3.725975252817087*^9, 3.7259752548932056`*^9}, {3.7259752864320097`*^9, 
   3.725975289801203*^9}, 3.725975322131052*^9, 3.7259753545829077`*^9, {
   3.7259754974490795`*^9, 3.7259755232805567`*^9}, {3.725975563454855*^9, 
   3.725975588667297*^9}, 3.725975645441544*^9, 3.725975912794836*^9, {
   3.7259767322667065`*^9, 3.7259767777723093`*^9}, {3.7259768351155896`*^9, 
   3.72597683948584*^9}, {3.7259770115736823`*^9, 3.7259770124347315`*^9}, {
   3.725977843585271*^9, 3.7259778513217134`*^9}, 3.7259780865771694`*^9, {
   3.7259782106042633`*^9, 3.725978215138522*^9}, {3.725979573613223*^9, 
   3.725979578259488*^9}, {3.7259796622902946`*^9, 3.7259796627033186`*^9}, {
   3.7259797689373946`*^9, 3.7259797707714996`*^9}, {3.725982056292224*^9, 
   3.7259820623565702`*^9}, {3.7259823008802137`*^9, 3.725982304503421*^9}, 
   3.7259824300226*^9, {3.7259826255427833`*^9, 3.725982633688249*^9}, 
   3.726052533189146*^9, 3.72605654642269*^9, {3.726056584168849*^9, 
   3.726056584394862*^9}, {3.726056735840524*^9, 3.726056842057599*^9}, {
   3.7260569594213123`*^9, 3.726057006338996*^9}, {3.7260573801133747`*^9, 
   3.726057415089375*^9}, {3.7260576067103353`*^9, 3.726057621991209*^9}, {
   3.726057705075961*^9, 3.726057745505274*^9}, {3.7260577882457185`*^9, 
   3.726057788350724*^9}, 3.7260578532684374`*^9, {3.726058168965494*^9, 
   3.726058191954809*^9}, 3.7260584572559834`*^9, 3.7260585510203466`*^9, 
   3.7260586693901167`*^9, {3.7260587136876507`*^9, 3.7260587150287275`*^9}, 
   3.7260587885099297`*^9, {3.7260588803901854`*^9, 3.7260588874085865`*^9}, {
   3.726065395157809*^9, 3.7260654081495523`*^9}, 3.7260656730857053`*^9, 
   3.7261505320115995`*^9, {3.726150817149908*^9, 3.7261508223902082`*^9}, {
   3.7261508610924215`*^9, 3.726150863175541*^9}, {3.7261509226079397`*^9, 
   3.7261509268461823`*^9}, {3.7261510114810233`*^9, 3.7261510127760973`*^9}, 
   3.7261510472260675`*^9, 3.726151239068041*^9, {3.7262219221653395`*^9, 
   3.7262219459126973`*^9}, {3.726572778538774*^9, 3.72657296396938*^9}, {
   3.726575277551709*^9, 3.7265753263424997`*^9}, {3.72657919038251*^9, 
   3.726579245115641*^9}, {3.726579328005382*^9, 3.7265793459474087`*^9}, {
   3.7265794571257677`*^9, 3.7265794576507974`*^9}, {3.7265799193752065`*^9, 
   3.726580062607399*^9}, {3.7265802511051807`*^9, 3.726580253477316*^9}, {
   3.7265802907774496`*^9, 3.7265803011860447`*^9}, 3.726580332100813*^9, 
   3.726580472134823*^9, {3.7266782584229593`*^9, 3.7266782584839625`*^9}, {
   3.7266783520883164`*^9, 3.726678380217925*^9}, {3.7266784821867576`*^9, 
   3.7266784823207655`*^9}, {3.7266787722723494`*^9, 3.726678775699546*^9}, {
   3.7267378871756425`*^9, 3.7267378926259546`*^9}, {3.7267380012321663`*^9, 
   3.7267380443816347`*^9}, 3.7267383395445166`*^9, {3.7267386874814177`*^9, 
   3.726738687681429*^9}, {3.7267444538442345`*^9, 3.7267444738113766`*^9}, {
   3.7267445078853254`*^9, 3.7267445116465406`*^9}, {3.7267457891266084`*^9, 
   3.726745799611208*^9}, 3.726745894313625*^9, {3.7267459474936666`*^9, 
   3.7267459805325565`*^9}, {3.7267460135954475`*^9, 3.72674601364145*^9}, {
   3.7267460666484814`*^9, 3.7267461243247805`*^9}, {3.726746174803668*^9, 
   3.7267461757657228`*^9}, {3.726746250501998*^9, 3.7267462517090664`*^9}, {
   3.726746297312675*^9, 3.726746303088005*^9}, {3.7267463504067116`*^9, 
   3.726746381343481*^9}, {3.7267464139183445`*^9, 3.7267464155854397`*^9}, {
   3.7267464517585087`*^9, 3.7267464864564934`*^9}, 3.726819600791639*^9, {
   3.7268197192754154`*^9, 3.726819719388422*^9}, {3.7268198949364634`*^9, 
   3.72681997041078*^9}, {3.72682000135955*^9, 3.726820003057647*^9}, 
   3.72691757275277*^9, {3.727072630144998*^9, 3.7270726344392433`*^9}, {
   3.7270727025001364`*^9, 3.7270727041672316`*^9}, {3.7270728599741435`*^9, 
   3.727072918786507*^9}, {3.7270729491822457`*^9, 3.7270729909026318`*^9}, {
   3.727073513310512*^9, 3.727073542136161*^9}, {3.727074679458212*^9, 
   3.7270748814547653`*^9}, {3.727075074493807*^9, 3.7270750745778117`*^9}, {
   3.7270945860178022`*^9, 3.7270946626231833`*^9}, {3.7270947251547604`*^9, 
   3.727094761848859*^9}, {3.7270947954997835`*^9, 3.7270948121007333`*^9}, {
   3.7270948538851233`*^9, 3.7270949068631535`*^9}, {3.7270950033696733`*^9, 
   3.727095089821618*^9}, 3.727095232651553*^9, {3.7270952690986376`*^9, 
   3.727095271704787*^9}, {3.727095339118643*^9, 3.7270953396516733`*^9}, {
   3.727095959410121*^9, 3.7270959750520163`*^9}, {3.7270961075605946`*^9, 
   3.7270961520811415`*^9}, {3.727096333395512*^9, 3.7270963427230453`*^9}, {
   3.7270965519610133`*^9, 3.7270966642324347`*^9}, {3.7270967194025908`*^9, 
   3.7270967202946415`*^9}, 3.7270969294026017`*^9, {3.7271625649643507`*^9, 
   3.7271625827703686`*^9}, {3.727162660482814*^9, 3.7271626620939054`*^9}, {
   3.727163375511711*^9, 3.727163405971453*^9}, {3.7271634883771667`*^9, 
   3.7271634889061966`*^9}, {3.727163542124241*^9, 3.7271635923131113`*^9}, {
   3.7271643657323484`*^9, 3.727164372091712*^9}, {3.7271644136430883`*^9, 
   3.7271644879673395`*^9}, 3.727164521644266*^9, {3.727174777862838*^9, 
   3.7271747779968452`*^9}, {3.727359715845685*^9, 3.7273597179218035`*^9}, {
   3.7273599821989193`*^9, 3.7273599829359617`*^9}, 3.7273601710737224`*^9, 
   3.727362167636919*^9, {3.7274230101644087`*^9, 3.727423014298645*^9}, {
   3.727440638677702*^9, 3.7274406636271296`*^9}, 3.7274406964070044`*^9, 
   3.727440731352003*^9, {3.7274407796657662`*^9, 3.7274408067343144`*^9}, {
   3.727510206731958*^9, 3.72751020764401*^9}, 3.7275103904494658`*^9, {
   3.727527978340436*^9, 3.727528016145598*^9}, {3.727535745583697*^9, 
   3.7275357715461817`*^9}, {3.7275519585534515`*^9, 3.727551999871815*^9}, {
   3.727552131153324*^9, 3.7275522351042695`*^9}, {3.727552655918339*^9, 
   3.7275527050771503`*^9}, {3.727552771365942*^9, 3.727552784072669*^9}, {
   3.72755285070848*^9, 3.727552853584645*^9}, {3.727554772658409*^9, 
   3.7275547869542274`*^9}, 3.7610435364817405`*^9, {3.761043571231025*^9, 
   3.761043576165954*^9}, {3.7610436235881033`*^9, 3.7610436413449106`*^9}, {
   3.7610436729002457`*^9, 3.761043770878871*^9}, {3.7610438475156293`*^9, 
   3.7610438647290735`*^9}, {3.7610443741135235`*^9, 3.761044401042234*^9}, {
   3.7618924178069444`*^9, 3.761892420698386*^9}, {3.761892490182556*^9, 
   3.7618924929984612`*^9}, {3.761892545538104*^9, 3.761892574421073*^9}, {
   3.7618943501822863`*^9, 3.761894355806435*^9}, 3.7618944420269365`*^9, {
   3.761894590484105*^9, 3.7618945909553003`*^9}, {3.765706575514555*^9, 
   3.7657065967311754`*^9}, {3.7657069762490983`*^9, 3.765706998624098*^9}, {
   3.7657827346196156`*^9, 3.7657827346804476`*^9}, {3.7657827662081413`*^9, 
   3.765782776262255*^9}, {3.7657828291219053`*^9, 3.7657829030262814`*^9}, {
   3.765792704839733*^9, 3.765792713891528*^9}, {3.7657927941309633`*^9, 
   3.765792854728921*^9}, {3.7657928892486134`*^9, 3.7657929295766582`*^9}, {
   3.765792979001932*^9, 3.7657930204449406`*^9}, {3.7657931294908957`*^9, 
   3.7657931374256454`*^9}, {3.7657931713717318`*^9, 
   3.7657931859776144`*^9}, {3.7657939720100403`*^9, 
   3.7657941210305495`*^9}, {3.7657941752425876`*^9, 
   3.7657942749356403`*^9}, {3.7657943083572693`*^9, 3.765794317829939*^9}, 
   3.76579434791549*^9, {3.765794438973993*^9, 3.7657945077181673`*^9}, {
   3.765795044879264*^9, 3.7657950752816195`*^9}, 3.7657960529456987`*^9, 
   3.7657973933299627`*^9, 3.765866685458251*^9, {3.765866741061284*^9, 
   3.7658667423029637`*^9}, {3.7658675605738115`*^9, 3.765867632896985*^9}, {
   3.76586808998555*^9, 3.7658681576486278`*^9}, {3.765870398400258*^9, 
   3.765870398502982*^9}, {3.765870746165774*^9, 3.765870746206662*^9}, {
   3.765874668191653*^9, 3.765874668660451*^9}, {3.7658747061050673`*^9, 
   3.765874729806857*^9}, {3.765875398319106*^9, 3.765875401117617*^9}, {
   3.765876280541726*^9, 3.76587629695483*^9}, {3.7658763346779566`*^9, 
   3.765876338007025*^9}, {3.765876902981591*^9, 3.7658769609724207`*^9}, {
   3.7658770973194704`*^9, 3.7658770998766603`*^9}, {3.7658771811591372`*^9, 
   3.7658771850627003`*^9}, {3.7658772670901785`*^9, 
   3.7658772777028255`*^9}, {3.765877315014012*^9, 3.765877352872703*^9}, {
   3.765877425541308*^9, 3.765877426344161*^9}, {3.76587748017918*^9, 
   3.765877480255975*^9}, {3.7658775192685795`*^9, 3.765877539390752*^9}, {
   3.7658776192561045`*^9, 3.7658776350189996`*^9}, {3.765877844409308*^9, 
   3.7658778654739313`*^9}, {3.7658781572475634`*^9, 
   3.7658781732168517`*^9}, {3.7658785536763487`*^9, 
   3.7658785537621183`*^9}, {3.765878723204729*^9, 3.7658787278354254`*^9}, {
   3.765878821034837*^9, 3.765878824716008*^9}, {3.7658788602087345`*^9, 
   3.765878906257386*^9}, {3.7658789742188053`*^9, 3.765878977583871*^9}, {
   3.7658790137815223`*^9, 3.7658790168971925`*^9}, {3.7658799376814375`*^9, 
   3.7658799503366623`*^9}, {3.7658802835697455`*^9, 3.765880284330738*^9}, {
   3.7658803589922943`*^9, 3.7658803634055367`*^9}, {3.7658803953571463`*^9, 
   3.765880397842506*^9}, {3.765880428410843*^9, 3.7658804292576137`*^9}, {
   3.7658805076082697`*^9, 3.765880507758868*^9}, {3.7658805416603003`*^9, 
   3.765880560977695*^9}, {3.7658806147939253`*^9, 3.7658806186366596`*^9}, {
   3.765880689523216*^9, 3.7658807745617647`*^9}, {3.7658808085188737`*^9, 
   3.7658808113652554`*^9}, {3.7658808656150513`*^9, 
   3.7658808672945523`*^9}, {3.765884258963793*^9, 3.765884276245948*^9}, {
   3.7658848692984433`*^9, 3.765884895979295*^9}, {3.765884941039137*^9, 
   3.7658849467099524`*^9}, {3.7658850008335857`*^9, 
   3.7658850086916256`*^9}, {3.765885087197223*^9, 3.765885102892359*^9}, {
   3.767001403833307*^9, 3.767001408035447*^9}, 3.767072356048971*^9, {
   3.7670724191411943`*^9, 3.7670724494980583`*^9}, {3.768893865727254*^9, 
   3.768893891122732*^9}, {3.7688945439884176`*^9, 3.768894544740034*^9}, {
   3.7688945986450815`*^9, 3.7688946343340454`*^9}, {3.768894749355147*^9, 
   3.7688947878920264`*^9}, {3.7688949238677526`*^9, 3.768894954747985*^9}, {
   3.7689038263403683`*^9, 3.7689038282929125`*^9}, {3.768903915431242*^9, 
   3.7689039197578783`*^9}, {3.768904091492632*^9, 3.7689041150608983`*^9}, {
   3.7689041650389643`*^9, 3.768904182034179*^9}, {3.768905401412935*^9, 
   3.7689054035910573`*^9}, {3.7689054852734146`*^9, 
   3.7689055132666073`*^9}, {3.76890561559*^9, 3.768905636101339*^9}, {
   3.7689984908949623`*^9, 3.768998492197207*^9}, {3.7689986706032896`*^9, 
   3.7689986707504272`*^9}, 3.76900051144162*^9, {3.769667292429305*^9, 
   3.76966732283525*^9}, {3.769667411801306*^9, 3.7696674128681464`*^9}, {
   3.7696674494975157`*^9, 3.7696674771269746`*^9}, {3.7696675279533386`*^9, 
   3.769667536844982*^9}, {3.7696675837476463`*^9, 3.769667587877054*^9}, {
   3.7697477473142405`*^9, 3.7697477641227903`*^9}, {3.769747797271249*^9, 
   3.7697478544453297`*^9}, {3.769748134123003*^9, 3.7697481445893335`*^9}, {
   3.7697482343182077`*^9, 3.769748238411008*^9}, {3.769748280697935*^9, 
   3.7697482912423325`*^9}, {3.7697490009661984`*^9, 
   3.7697490204772377`*^9}, {3.7697490770108285`*^9, 
   3.7697491081128883`*^9}, {3.7697492058243017`*^9, 3.769749224460558*^9}, {
   3.7697492789165*^9, 3.769749297896429*^9}, {3.7697493449166307`*^9, 
   3.7697493610846944`*^9}, 3.769750101598489*^9, {3.769752151792632*^9, 
   3.769752271978362*^9}, {3.7697524382321973`*^9, 3.7697524960300493`*^9}, {
   3.7697530394500003`*^9, 3.769753092035779*^9}, {3.769753178265218*^9, 
   3.7697532130028305`*^9}, {3.7697532703222885`*^9, 3.769753292540619*^9}, {
   3.7697533741636252`*^9, 3.769753436044987*^9}, {3.7697535132179327`*^9, 
   3.769753516665329*^9}, 3.7697535818502827`*^9, {3.769922030223013*^9, 
   3.769922053699747*^9}, {3.7699224451857543`*^9, 3.769922486638294*^9}, {
   3.7699254723034325`*^9, 3.769925473271984*^9}, {3.771660100115201*^9, 
   3.7716601062800055`*^9}, {3.77166053487606*^9, 3.7716606259878173`*^9}, {
   3.7716623761238966`*^9, 3.7716623779596643`*^9}, {3.7716678911254325`*^9, 
   3.7716679089924345`*^9}, {3.7716679454177*^9, 3.77166799233274*^9}, {
   3.7716695970190773`*^9, 3.771669600389398*^9}, {3.771677568982067*^9, 
   3.7716775766050835`*^9}, {3.7716782969564185`*^9, 3.771678360053693*^9}, {
   3.7716784267759666`*^9, 3.7716784284344177`*^9}, {3.7716784911055613`*^9, 
   3.771678522673049*^9}, {3.7716785548654757`*^9, 3.771678589214897*^9}, {
   3.7716796500115128`*^9, 3.7716796836316442`*^9}, {3.771743068876005*^9, 
   3.7717430689298563`*^9}, {3.77174466019594*^9, 3.7717446622579923`*^9}, {
   3.771755638956787*^9, 3.7717556494710464`*^9}, {3.7717557338724613`*^9, 
   3.7717558208535852`*^9}, {3.7717564613961935`*^9, 3.771756483394667*^9}, {
   3.7717565588132677`*^9, 3.7717565847653637`*^9}, {3.771758180176942*^9, 
   3.7717581952406173`*^9}, {3.7719282620047493`*^9, 3.771928274281084*^9}, {
   3.773053676650999*^9, 3.773053690522129*^9}, 3.773063978148549*^9, {
   3.7731234898213634`*^9, 3.7731235282751245`*^9}, {3.775375371997332*^9, 
   3.7753753755161343`*^9}, {3.775381879597662*^9, 3.7753820307799625`*^9}, {
   3.7753822258368473`*^9, 3.775382269230371*^9}, {3.775382400406457*^9, 
   3.7753824182754817`*^9}, 3.775382551223713*^9, {3.77597032999426*^9, 
   3.775970330447278*^9}, {3.7759705888399467`*^9, 3.775970721027199*^9}, {
   3.7759710485869637`*^9, 3.7759710887198963`*^9}, {3.775971474224698*^9, 
   3.7759714748964148`*^9}, {3.775971532707755*^9, 3.7759715330955353`*^9}, {
   3.7759721163234186`*^9, 3.7759721173075643`*^9}, {3.7759738730554285`*^9, 
   3.7759740309008923`*^9}, {3.7759748008302064`*^9, 3.775974913086027*^9}, {
   3.7759750283600225`*^9, 3.775975032209963*^9}, {3.7759751833425517`*^9, 
   3.7759751865228715`*^9}, {3.7759754025482993`*^9, 3.77597544571861*^9}, {
   3.7759755157361407`*^9, 3.7759756273651576`*^9}, {3.7759757606940885`*^9, 
   3.775975784107974*^9}, {3.775976434150741*^9, 3.775976467643176*^9}, {
   3.7759765378057933`*^9, 3.775976600400424*^9}, {3.7759767817857*^9, 
   3.775976802977689*^9}, {3.77597691101481*^9, 3.7759769237682476`*^9}, {
   3.775977046928296*^9, 3.7759770513506327`*^9}, {3.775977139852575*^9, 
   3.7759772599952807`*^9}, {3.7759773025624247`*^9, 3.775977342687679*^9}, {
   3.775977809838889*^9, 3.775977812310458*^9}, {3.775978173456747*^9, 
   3.775978182960619*^9}, {3.7759783529285316`*^9, 3.7759783732318764`*^9}, {
   3.7759784908419094`*^9, 3.7759785383017845`*^9}, {3.7759787050729647`*^9, 
   3.7759787148939123`*^9}, {3.775978815087892*^9, 3.77597881521286*^9}, {
   3.775978887670947*^9, 3.7759789094696665`*^9}, {3.7759789669034915`*^9, 
   3.775978966965975*^9}, {3.77597905925445*^9, 3.77597905939504*^9}, {
   3.77597931651031*^9, 3.7759793438810096`*^9}, {3.775979393248663*^9, 
   3.775979396861303*^9}, {3.775979493900787*^9, 3.775979498870141*^9}, {
   3.7759795704519544`*^9, 3.7759795719515963`*^9}, {3.775980367498499*^9, 
   3.775980373688101*^9}, {3.7759804334722986`*^9, 3.7759804394118643`*^9}, {
   3.775980470034383*^9, 3.7759804759416084`*^9}, {3.7759805213187113`*^9, 
   3.7759805265232625`*^9}, {3.775980596710368*^9, 3.775980597866354*^9}, {
   3.775980685440336*^9, 3.775980701194945*^9}, {3.775980801032648*^9, 
   3.7759808040813193`*^9}, {3.775980906504019*^9, 3.775980943761853*^9}, {
   3.7759810222523394`*^9, 3.775981029988222*^9}, {3.775981071593402*^9, 
   3.775981137893276*^9}, {3.7759812064539804`*^9, 3.7759812173457317`*^9}, {
   3.775981267186038*^9, 3.7759812889275665`*^9}, {3.775981367822196*^9, 
   3.7759813933659244`*^9}, {3.7759814908037863`*^9, 3.775981512309603*^9}, {
   3.775982191035874*^9, 3.775982270888726*^9}, {3.775982659747901*^9, 
   3.775982715980893*^9}, {3.775983088714069*^9, 3.7759831014937725`*^9}, {
   3.775983479476821*^9, 3.775983494015912*^9}, {3.775984157083788*^9, 
   3.775984189105794*^9}, {3.775987638218315*^9, 3.775987669492136*^9}, {
   3.7759877882950287`*^9, 3.7759878103737164`*^9}, {3.7759879407630053`*^9, 
   3.77598794732751*^9}, {3.7759884426335487`*^9, 3.7759884433833733`*^9}, {
   3.7759903836128483`*^9, 3.7759903891335106`*^9}, {3.775990536786618*^9, 
   3.775990537630173*^9}, {3.775991052511698*^9, 3.77599109547548*^9}, {
   3.776056992233425*^9, 3.776057069303294*^9}, {3.776057153335003*^9, 
   3.7760571823878765`*^9}, {3.7760572182036057`*^9, 
   3.7760573256045346`*^9}, {3.77605742420984*^9, 3.7760574270080004`*^9}, {
   3.7760575890959277`*^9, 3.7760576223432865`*^9}, {3.776057657480855*^9, 
   3.776057745252927*^9}, {3.7760577990605288`*^9, 3.7760578380112743`*^9}, {
   3.7760604287191863`*^9, 3.77606046598678*^9}, {3.7760619884688883`*^9, 
   3.776062072334055*^9}, {3.7760627885494223`*^9, 3.7760627981098127`*^9}, {
   3.7760750179446545`*^9, 3.776075020666136*^9}, {3.7764888645709724`*^9, 
   3.7764889098753557`*^9}, {3.776489328125409*^9, 3.7764893391100535`*^9}, {
   3.77649131423363*^9, 3.7764913192681317`*^9}, {3.7764916880966997`*^9, 
   3.776491723375167*^9}, {3.7764926384497523`*^9, 3.7764927740143375`*^9}, {
   3.7764928183674555`*^9, 3.7764928867245255`*^9}, {3.7764945679353523`*^9, 
   3.7764946137514715`*^9}, {3.776495453736725*^9, 3.776495503977549*^9}, 
   3.7764955944029465`*^9, {3.776496911278183*^9, 3.7764969331721306`*^9}, 
   3.7764973570621305`*^9, {3.7764983447840176`*^9, 3.7764984575630236`*^9}, 
   3.7764985889090443`*^9, {3.776499585795329*^9, 3.776499585982813*^9}, {
   3.7764996323471537`*^9, 3.7764996341553574`*^9}, {3.7765011925631084`*^9, 
   3.776501230502634*^9}, 3.776501264702818*^9, {3.7765046444826655`*^9, 
   3.7765046472113724`*^9}, {3.776507174468521*^9, 3.7765072183103795`*^9}, 
   3.7765080755665674`*^9, {3.7782235757323546`*^9, 3.778223577241416*^9}, {
   3.7789220404263115`*^9, 3.7789220630006003`*^9}, 3.7789221044667997`*^9, {
   3.7789221359072857`*^9, 3.7789221586896644`*^9}, {3.7789237311543007`*^9, 
   3.7789237591190524`*^9}, {3.793018120756835*^9, 3.793018123576969*^9}, {
   3.7930181900905676`*^9, 3.7930181940923815`*^9}, 3.793035980039872*^9, {
   3.793106335043481*^9, 3.7931063531114197`*^9}, {3.7931164191303134`*^9, 
   3.7931164223439703`*^9}, {3.7967322254312787`*^9, 
   3.7967322355513597`*^9}, {3.902889006465725*^9, 3.902889019529697*^9}, {
   3.902889534197481*^9, 3.9028895844001904`*^9}, {3.9028905713848057`*^9, 
   3.902890571752976*^9}, 3.902905333331485*^9, {3.902976100673369*^9, 
   3.9029761074935617`*^9}, {3.902976968928012*^9, 3.9029769708431597`*^9}, {
   3.902977032936584*^9, 3.902977036967963*^9}, {3.9030687792080812`*^9, 
   3.903068807681006*^9}},
 CellLabel->"In[12]:=",ExpressionUUID->"f7b7db0c-e37c-4f4b-a5ba-b83ff4e8eedf"]
}, Closed]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{"Smooths", " ", "UK", " ", "survival", " ", "probabilities"}], 
  "*)"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10002.},
 CellChangeTimes->{{3.8634350432728453`*^9, 3.8634350533435345`*^9}, 
   3.863435097838857*^9, 3.8634351376451645`*^9, 3.863435795747896*^9, 
   3.89876554063846*^9, 3.903068832931925*^9},
 CellLabel->"In[13]:=",ExpressionUUID->"137a0b85-9312-4bcd-987f-05e5f57e678e"],

Cell[BoxData[
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"smoothSurvProbs", "[", 
     RowBox[{"dataImport_", ",", "initYear_", ",", "terminYear_"}], "]"}], ":=", 
    RowBox[{"Module", "[", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{
        RowBox[{"data", "=", "dataImport"}], ",", "A", ",", "K", ",", "Ce", 
        ",", "Q", ",", "\[Nu]", ",", "fit", ",", "x"}], "}"}], ",", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"(*", 
       RowBox[{
        RowBox[{"A", "=", 
         RowBox[{"data", "[", 
          RowBox[{"[", 
           RowBox[{"1", ",", "2"}], "]"}], "]"}]}], ";"}], " ", 
       RowBox[{"(*", 
        RowBox[{"min", " ", "assymptote"}], "*)"}], "*)"}], 
      "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"A", "=", 
        RowBox[{"Mean", "[", 
         RowBox[{
          RowBox[{"data", "[", 
           RowBox[{"[", 
            RowBox[{"All", ",", "2"}], "]"}], "]"}], "[", 
          RowBox[{"[", 
           RowBox[{"1", ";;", "10"}], "]"}], "]"}], "]"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"K", "=", "0.666667"}], ";", " ", 
       RowBox[{"(*", 
        RowBox[{"max", " ", "assymptote"}], "*)"}], "\[IndentingNewLine]", 
       RowBox[{"Ce", "=", "1"}], ";", 
       RowBox[{"Q", "=", "1"}], ";", 
       RowBox[{"\[Nu]", "=", "1"}], ";", "\[IndentingNewLine]", 
       "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{"fit", "=", 
        RowBox[{"FindFit", "[", 
         RowBox[{"data", ",", 
          RowBox[{"A", " ", "+", 
           FractionBox[
            RowBox[{"K", "-", "A"}], 
            SuperscriptBox[
             RowBox[{"(", 
              RowBox[{"Ce", "+", 
               RowBox[{"Q", " ", 
                SuperscriptBox["E", 
                 RowBox[{
                  RowBox[{"-", "B"}], 
                  RowBox[{"(", 
                   RowBox[{
                    FractionBox[
                    RowBox[{"t", "-", "1550"}], "25"], "-", "M"}], 
                   ")"}]}]]}]}], ")"}], 
             FractionBox["1", "\[Nu]"]]]}], ",", 
          RowBox[{"{", 
           RowBox[{
            RowBox[{"{", 
             RowBox[{"B", ",", "2"}], "}"}], ",", 
            RowBox[{"{", 
             RowBox[{"M", ",", "10"}], "}"}]}], "}"}], ",", "t"}], "]"}]}], 
       ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"x", "[", "t_", "]"}], ":=", 
        RowBox[{"(", 
         RowBox[{
          RowBox[{"(", 
           RowBox[{"A", " ", "+", 
            FractionBox[
             RowBox[{"K", "-", "A"}], 
             SuperscriptBox[
              RowBox[{"(", 
               RowBox[{"Ce", "+", 
                RowBox[{"Q", " ", 
                 SuperscriptBox["E", 
                  RowBox[{
                   RowBox[{"-", "B"}], 
                   RowBox[{"(", 
                    RowBox[{
                    FractionBox[
                    RowBox[{"t", "-", "1550"}], "25"], "-", "M"}], 
                    ")"}]}]]}]}], ")"}], 
              FractionBox["1", "\[Nu]"]]]}], ")"}], "/.", "fit"}], ")"}]}], 
       ";", "\[IndentingNewLine]", 
       RowBox[{"Return", "[", 
        RowBox[{"Table", "[", 
         RowBox[{
          RowBox[{"{", 
           RowBox[{"t", ",", 
            RowBox[{
             RowBox[{"(", 
              RowBox[{"A", " ", "+", 
               FractionBox[
                RowBox[{"K", "-", "A"}], 
                SuperscriptBox[
                 RowBox[{"(", 
                  RowBox[{"Ce", "+", 
                   RowBox[{"Q", " ", 
                    SuperscriptBox["E", 
                    RowBox[{
                    RowBox[{"-", "B"}], 
                    RowBox[{"(", 
                    RowBox[{
                    FractionBox[
                    RowBox[{"t", "-", "1550"}], "25"], "-", "M"}], 
                    ")"}]}]]}]}], ")"}], 
                 FractionBox["1", "\[Nu]"]]]}], ")"}], "/.", "fit"}]}], "}"}],
           ",", 
          RowBox[{"{", 
           RowBox[{"t", ",", "initYear", ",", "terminYear", ",", "25"}], 
           "}"}]}], "]"}], "]"}], ";"}]}], "\[IndentingNewLine]", "]"}]}], 
   ";"}], "\[IndentingNewLine]"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10002.},
 CellChangeTimes->{{3.8634349081726446`*^9, 3.8634349504789796`*^9}, {
   3.863435034817171*^9, 3.863435097838857*^9}, 3.8634351376451645`*^9, 
   3.863435795747896*^9, {3.8634360047399483`*^9, 3.863436179446647*^9}, {
   3.863436731953865*^9, 3.8634367330379906`*^9}, {3.8634369983029985`*^9, 
   3.863436999335122*^9}, 3.86343735985695*^9, 3.863438219391926*^9, {
   3.863492935068217*^9, 3.863492942329256*^9}, {3.8634930742218604`*^9, 
   3.863493077982755*^9}, {3.863494638150253*^9, 3.8634946421693983`*^9}, {
   3.8634949386564474`*^9, 3.863494948970192*^9}, {3.8634953463036623`*^9, 
   3.863495365007922*^9}, 3.863495498398093*^9, {3.8634956909785705`*^9, 
   3.863495726424425*^9}, {3.894341879174224*^9, 3.894341886044139*^9}, {
   3.894965638105673*^9, 3.894965638646646*^9}, {3.8949657728539553`*^9, 
   3.894965773177616*^9}, {3.8949658682749557`*^9, 3.894965868869503*^9}, {
   3.8967574545340853`*^9, 3.896757508967289*^9}, {3.896757574977531*^9, 
   3.896757575112473*^9}, 3.898595037684162*^9, {3.898595128030019*^9, 
   3.898595128564797*^9}, {3.898595226443963*^9, 3.898595238273301*^9}, 
   3.898595342705102*^9, {3.898747280190014*^9, 3.8987472808005543`*^9}, {
   3.8987479900384493`*^9, 3.898747990395775*^9}, 3.898765540638748*^9, 
   3.9027227525798597`*^9, 3.90293145755767*^9, 3.902981558995697*^9},
 CellLabel->"In[14]:=",ExpressionUUID->"ce49bceb-045f-4747-a724-9152dae73fb7"]
}, Closed]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{
   RowBox[{
    RowBox[{
     RowBox[{
      RowBox[{"smoothedLevelsFromGrowth", "[", 
       RowBox[{"grcuttoff_", ",", "startyear_", ",", "endyear_"}], "]"}], " ",
       "--"}], " ", "Provide", " ", "as", " ", "input", " ", "a", " ", 
     "vector", " ", "grcuttoff", " ", "showing", " ", "what", " ", "a", " ", 
     "growth", " ", "rate", " ", "is", " ", "up", " ", "to", " ", "a", " ", 
     "certain", " ", "year", " ", "and", " ", "the", " ", "desired", " ", 
     "start", " ", "and", " ", "end", " ", "date", " ", "of", " ", "your", 
     " ", "series", " ", "module", " ", "then", " ", "generates", " ", 
     "smooothed", " ", "levels", " ", "corresponding", " ", "to", " ", 
     "those", " ", "growth", " ", 
     RowBox[{"rates", ".", " ", "Notice"}], " ", "that", " ", "growth", " ", 
     "rates", " ", "take", " ", "the", " ", "form", " ", "g_", 
     RowBox[{"{", 
      RowBox[{"N", ",", 
       RowBox[{"t", "+", "1"}]}], "}"}]}], "==", 
    RowBox[{"N_", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{"t", "+", "1"}], "}"}], "/", 
      RowBox[{"N_t", ".", " ", "For"}]}], " ", "example"}]}], ",", " ", 
   RowBox[{"gNCutoffs", "\[Rule]", 
    RowBox[{"{", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{"1775", ",", "1.045340675"}], "}"}], ",", 
      RowBox[{"{", 
       RowBox[{"1875", ",", "1.109693257"}], "}"}], ",", 
      RowBox[{"{", 
       RowBox[{"2000", ",", "1.404081875"}], "}"}]}], "}"}]}], ",", " ", 
   RowBox[{
    RowBox[{"the", " ", "point", " ", 
     RowBox[{"{", 
      RowBox[{"1775", ",", "1.045340675"}], "}"}], " ", "refers", " ", "to", 
     " ", "a", " ", "growth", " ", "factor", " ", "from", " ", "1750", " ", 
     "to", " ", "1775", " ", "of", " ", 
     RowBox[{"1.045340675", ".", " ", "This"}], " ", "then", " ", "fits", " ",
      "a", " ", "generalized", " ", "logistic", " ", "function", " ", "to", 
     " ", "the", " ", "cutoffs", " ", "to", " ", "make", " ", "growth", " ", 
     "rates", " ", "smooth", " ", "and", " ", "uses", " ", "the", " ", 
     "smoothed", " ", "growth", " ", "rate", " ", "to", " ", "return", " ", 
     "a", " ", "index", " ", "series", " ", "from", " ", "start", " ", "year",
      " ", "to", " ", "end", " ", 
     RowBox[{"year", ".", " ", "Notice"}], " ", "start", " ", "year", " ", 
     "refers", " ", "to", " ", "the", " ", "initial", " ", "year", " ", 
     "that", " ", "the", " ", "level", " ", "goes", " ", 
     RowBox[{"from", ".", " ", "Growth"}], " ", "rates", " ", "will", " ", 
     "go", " ", "from", " ", "the", " ", "subsequent", " ", 
     RowBox[{"period", ".", " ", "i", ".", "e", ".", " ", "if"}], " ", 
     "startyear"}], "=", "1275"}], ",", " ", 
   RowBox[{
   "then", " ", "the", " ", "first", " ", "growth", " ", "rate", " ", "will", 
    " ", "be", " ", "g_", 
    RowBox[{"{", "1300", "}"}], " ", "and", " ", "will", " ", "indicate", " ",
     "the", " ", "growth", " ", "from", " ", "1275", " ", "to", " ", "1300"}],
    ",", " ", 
   RowBox[{
   "but", " ", "the", " ", "initial", " ", "level", " ", "point", " ", "will",
     " ", "be", " ", "in", " ", "1275."}]}], "  ", "*)"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.},
 CellChangeTimes->{{3.8632548056087236`*^9, 3.8632549012556705`*^9}, 
   3.863254999614545*^9, {3.898576196481159*^9, 3.898576341212469*^9}, {
   3.903068872331047*^9, 3.9030688965174913`*^9}, {3.9030689272083187`*^9, 
   3.903068928798819*^9}},
 CellLabel->"In[15]:=",ExpressionUUID->"cfc7c8c1-2083-4ad0-b0f1-94dabb04af60"],

Cell[BoxData[
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"smoothedLevelsFromGrowth", "[", 
     RowBox[{"grco_", ",", "sy_", ",", "ey_"}], "]"}], ":=", 
    RowBox[{"Module", "[", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{
        RowBox[{"grcuttoff", "=", "grco"}], ",", 
        RowBox[{"startyear", "=", "sy"}], ",", 
        RowBox[{"endyear", "=", "ey"}], ",", "gN", ",", "data", ",", "A", ",",
         "K", ",", "Ce", ",", "Q", ",", "\[Nu]", ",", "B", ",", "M", ",", 
        "fit", ",", "x", ",", "d", ",", "ans"}], "}"}], ",", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"grcuttoff", "=", 
        RowBox[{"Join", "[", 
         RowBox[{"grcuttoff", ",", 
          RowBox[{"{", 
           RowBox[{"{", 
            RowBox[{"\[Infinity]", ",", 
             RowBox[{"grcuttoff", "[", 
              RowBox[{"[", 
               RowBox[{
                RowBox[{"Length", "[", "grcuttoff", "]"}], ",", "2"}], "]"}], 
              "]"}]}], "}"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"gN", "[", "year_", "]"}], ":=", 
        RowBox[{
         RowBox[{"grcuttoff", "[", 
          RowBox[{"[", 
           RowBox[{"All", ",", "2"}], "]"}], "]"}], "[", 
         RowBox[{"[", 
          RowBox[{
           RowBox[{"Flatten", "[", 
            RowBox[{"Position", "[", 
             RowBox[{
              RowBox[{"grcuttoff", "[", 
               RowBox[{"[", 
                RowBox[{"All", ",", "1"}], "]"}], "]"}], ",", 
              RowBox[{"Min", "@", 
               RowBox[{"Select", "[", 
                RowBox[{
                 RowBox[{"grcuttoff", "[", 
                  RowBox[{"[", 
                   RowBox[{"All", ",", "1"}], "]"}], "]"}], ",", 
                 RowBox[{
                  RowBox[{"#", ">=", " ", "year"}], "&"}]}], "]"}]}]}], "]"}],
             "]"}], "[", 
           RowBox[{"[", "1", "]"}], "]"}], "]"}], "]"}]}], ";", 
       "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{"data", "=", 
        RowBox[{"Table", "[", 
         RowBox[{
          RowBox[{"{", 
           RowBox[{"t", ",", 
            RowBox[{"gN", "[", "t", "]"}]}], "}"}], ",", 
          RowBox[{"{", 
           RowBox[{"t", ",", "startyear", ",", "endyear", ",", "25"}], 
           "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{"(*", 
        RowBox[{
         RowBox[{"Print", "[", "data", "]"}], ";"}], "*)"}], 
       "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{"A", "=", 
        RowBox[{"Min", "[", 
         RowBox[{"data", "[", 
          RowBox[{"[", 
           RowBox[{"All", ",", "2"}], "]"}], "]"}], "]"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"K", "=", 
        RowBox[{"Max", "[", 
         RowBox[{"data", "[", 
          RowBox[{"[", 
           RowBox[{"All", ",", "2"}], "]"}], "]"}], "]"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"Ce", "=", "1"}], ";", 
       RowBox[{"Q", "=", "1"}], ";", 
       RowBox[{"\[Nu]", "=", "1"}], ";", "\[IndentingNewLine]", 
       "\[IndentingNewLine]", 
       RowBox[{"fit", "=", 
        RowBox[{"FindFit", "[", 
         RowBox[{"data", ",", 
          RowBox[{"A", " ", "+", 
           FractionBox[
            RowBox[{"K", "-", "A"}], 
            SuperscriptBox[
             RowBox[{"(", 
              RowBox[{"Ce", "+", 
               RowBox[{"Q", " ", 
                SuperscriptBox["E", 
                 RowBox[{
                  RowBox[{"-", "B"}], 
                  RowBox[{"(", 
                   RowBox[{
                    FractionBox[
                    RowBox[{"t", "-", 
                    RowBox[{"(", 
                    RowBox[{"startyear", "+", "25"}], ")"}]}], "25"], "-", 
                    "M"}], ")"}]}]]}]}], ")"}], 
             FractionBox["1", "\[Nu]"]]]}], ",", 
          RowBox[{"{", 
           RowBox[{
            RowBox[{"{", 
             RowBox[{"B", ",", "1"}], "}"}], ",", 
            RowBox[{"{", 
             RowBox[{"M", ",", "5"}], "}"}]}], "}"}], ",", "t"}], "]"}]}], 
       ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"x", "[", "t_", "]"}], ":=", 
        RowBox[{"(", 
         RowBox[{
          RowBox[{"(", 
           RowBox[{"A", " ", "+", 
            FractionBox[
             RowBox[{"K", "-", "A"}], 
             SuperscriptBox[
              RowBox[{"(", 
               RowBox[{"Ce", "+", 
                RowBox[{"Q", " ", 
                 SuperscriptBox["E", 
                  RowBox[{
                   RowBox[{"-", "B"}], 
                   RowBox[{"(", 
                    RowBox[{
                    FractionBox[
                    RowBox[{"t", "-", 
                    RowBox[{"(", 
                    RowBox[{"startyear", "+", "25"}], ")"}]}], "25"], "-", 
                    "M"}], ")"}]}]]}]}], ")"}], 
              FractionBox["1", "\[Nu]"]]]}], ")"}], "/.", "fit"}], ")"}]}], 
       ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{"ans", "=", 
        RowBox[{"RecurrenceTable", "[", 
         RowBox[{
          RowBox[{"{", 
           RowBox[{
            RowBox[{
             RowBox[{"d", "[", 
              RowBox[{"n", "+", "1"}], "]"}], "\[Equal]", 
             RowBox[{
              RowBox[{"d", "[", "n", "]"}], "*", 
              RowBox[{"x", "[", 
               RowBox[{
                RowBox[{"n", "*", "25"}], "+", 
                RowBox[{"(", 
                 RowBox[{"startyear", "+", "25"}], ")"}]}], "]"}]}]}], ",", 
            RowBox[{
             RowBox[{"d", "[", "0", "]"}], "\[Equal]", "1"}]}], "}"}], ",", 
          "d", ",", 
          RowBox[{"{", 
           RowBox[{"n", ",", "0", ",", 
            FractionBox[
             RowBox[{"endyear", "-", "startyear"}], "25"]}], "}"}]}], "]"}]}],
        ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
       "\[IndentingNewLine]", 
       RowBox[{"Return", "[", 
        RowBox[{"Table", "[", 
         RowBox[{
          RowBox[{"{", 
           RowBox[{"t", ",", 
            RowBox[{"ans", "[", 
             RowBox[{"[", 
              RowBox[{
               FractionBox[
                RowBox[{"t", "-", "startyear"}], "25"], "+", "1"}], "]"}], 
             "]"}]}], "}"}], ",", 
          RowBox[{"{", 
           RowBox[{"t", ",", "startyear", ",", "endyear", ",", "25"}], 
           "}"}]}], "]"}], "]"}], ";"}]}], "\[IndentingNewLine]", "]"}]}], 
   ";"}], "\[IndentingNewLine]"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.},
 CellChangeTimes->{{3.863253750160207*^9, 3.863254055777777*^9}, {
   3.8632541587808743`*^9, 3.8632541845646496`*^9}, 3.8632542439864936`*^9, 
   3.8632543099817734`*^9, {3.8632544599288025`*^9, 3.863254499208193*^9}, {
   3.8632545691865816`*^9, 3.8632546099327917`*^9}, {3.863254643834134*^9, 
   3.863254663913598*^9}, 3.8632547732112045`*^9, {3.863254890160553*^9, 
   3.8632549012556705`*^9}, {3.8632550478553495`*^9, 
   3.8632550859335794`*^9}, {3.863255228427503*^9, 3.863255233104779*^9}, {
   3.8654198430585485`*^9, 3.8654198454159894`*^9}, {3.865419911299573*^9, 
   3.865419921546056*^9}, {3.865420057168458*^9, 3.865420060600258*^9}, {
   3.865420133186542*^9, 3.865420136633732*^9}, {3.8654202099278555`*^9, 
   3.8654202135253906`*^9}, {3.896522842869014*^9, 3.896522844907855*^9}, {
   3.8967576081309566`*^9, 3.896757721408883*^9}, {3.8985236932629147`*^9, 
   3.89852371292188*^9}, {3.898523809829134*^9, 3.8985238444005423`*^9}, {
   3.898571815228867*^9, 3.898571816393138*^9}, {3.898572447010049*^9, 
   3.898572448717448*^9}, {3.898574677268695*^9, 3.898574677763526*^9}, {
   3.898574747747571*^9, 3.898574748097891*^9}, {3.898574920746168*^9, 
   3.898574937218288*^9}, {3.898575034593892*^9, 3.8985750453877487`*^9}, 
   3.898576069778246*^9, {3.898587736437237*^9, 3.8985877478430967`*^9}, {
   3.8986593962567244`*^9, 3.8986593963769283`*^9}, 3.898659534718218*^9, 
   3.898659587913601*^9, {3.8986597088580513`*^9, 3.898659710471033*^9}, {
   3.898660225307333*^9, 3.898660251822547*^9}, {3.898660305717578*^9, 
   3.898660327605644*^9}, {3.898677446359129*^9, 3.8986774463926697`*^9}, {
   3.898681449511979*^9, 3.898681458052198*^9}, {3.902981567816532*^9, 
   3.9029815680796423`*^9}},
 CellLabel->"In[16]:=",ExpressionUUID->"a4178c52-68c2-4978-aa44-331136a1f4ed"]
}, Closed]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{"calibration", " ", "-", " ", 
   RowBox[{
   "module", " ", "used", " ", "for", " ", "calibration", " ", "of", " ", 
    "main", " ", "model"}]}], " ", "*)"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10002.},
 CellChangeTimes->{{3.8949455499060593`*^9, 3.894945550957348*^9}, 
   3.8949455945441713`*^9, 3.894947466883896*^9, 3.898765552579089*^9, {
   3.903068936297339*^9, 3.9030689626772423`*^9}},
 CellLabel->"In[17]:=",ExpressionUUID->"229dfa80-6c2b-4c86-9bd2-a460ae6843b6"],

Cell[BoxData[
 RowBox[{
  RowBox[{
   RowBox[{"calibration", "[", "inputData_", "]"}], ":=", 
   "\[IndentingNewLine]", 
   RowBox[{"Module", "[", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"gamma", ",", "ansss1", ",", "ansss2"}], "}"}], ",", 
     "\[IndentingNewLine]", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{
       RowBox[{"gamma", "[", "x_", "]"}], ":=", 
       SuperscriptBox["E", 
        RowBox[{"LogGamma", "[", "x", "]"}]]}], ";", "\[IndentingNewLine]", 
      RowBox[{"ansss1", "=", 
       RowBox[{"FindRoot", "[", 
        RowBox[{
         RowBox[{
          RowBox[{"{", 
           RowBox[{
            RowBox[{"gNss", "==", 
             RowBox[{
              RowBox[{"(", 
               RowBox[{
                RowBox[{
                 RowBox[{"-", "ass"}], " ", "Piess", " ", 
                 RowBox[{"(", 
                  RowBox[{
                   RowBox[{"-", "1"}], "+", "\[Alpha]"}], ")"}], " ", 
                 RowBox[{"(", 
                  RowBox[{"1", "+", 
                   RowBox[{"Piess", " ", 
                    SubscriptBox["\[Beta]", "1"], " ", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "\[Omega]"}], ")"}]}], "-", 
                   RowBox[{
                    SubscriptBox["\[Beta]", "1"], " ", "\[Omega]"}]}], 
                  ")"}]}], "+", 
                RowBox[{"ktildess", " ", 
                 RowBox[{"(", 
                  RowBox[{
                   RowBox[{"-", "1"}], "+", "\[Delta]"}], ")"}], " ", 
                 RowBox[{"(", 
                  RowBox[{
                   RowBox[{"-", "1"}], "+", "\[Alpha]", "+", 
                   RowBox[{
                    SubscriptBox["\[Beta]", "1"], " ", 
                    RowBox[{"(", 
                    RowBox[{"Piess", "+", "\[Omega]", "-", 
                    RowBox[{"Piess", " ", "\[Omega]"}]}], ")"}]}]}], ")"}]}], 
                "+", 
                RowBox[{
                 SuperscriptBox["ktildess", "\[Nu]"], " ", 
                 RowBox[{"(", 
                  RowBox[{"1", "-", 
                   RowBox[{"Piess", " ", 
                    SubscriptBox["\[Beta]", "1"]}], "+", 
                   RowBox[{
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "Piess"}], ")"}], " ", 
                    SubscriptBox["\[Beta]", "1"], " ", "\[Omega]"}], "+", 
                   RowBox[{"\[Alpha]", " ", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", 
                    RowBox[{
                    SubscriptBox["\[Beta]", "1"], " ", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "\[Nu]"}], ")"}], " ", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "Piess"}], "+", 
                    RowBox[{
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "Piess"}], ")"}], " ", 
                    "\[Omega]"}]}], ")"}]}]}], ")"}]}]}], ")"}]}]}], ")"}], 
              "/", 
              RowBox[{"(", 
               RowBox[{"ass", "+", 
                RowBox[{"ass", " ", "Piess", " ", 
                 SubscriptBox["\[Beta]", "1"], " ", 
                 RowBox[{"(", 
                  RowBox[{
                   RowBox[{"-", "1"}], "+", "\[Omega]"}], ")"}]}], "-", 
                RowBox[{"ass", " ", 
                 SubscriptBox["\[Beta]", "1"], " ", "\[Omega]"}], "-", 
                RowBox[{
                 SuperscriptBox["gDss", 
                  FractionBox["1", 
                   RowBox[{"1", "-", "\[Nu]"}]]], " ", "ktildess", " ", 
                 RowBox[{"(", 
                  RowBox[{
                   RowBox[{"-", "1"}], "+", "\[Alpha]", "+", 
                   RowBox[{
                    SubscriptBox["\[Beta]", "1"], " ", 
                    RowBox[{"(", 
                    RowBox[{"Piess", "+", "\[Omega]", "-", 
                    RowBox[{"Piess", " ", "\[Omega]"}]}], ")"}]}]}], 
                  ")"}]}]}], ")"}]}]}], ",", 
            RowBox[{"ktildess", "==", 
             SuperscriptBox[
              RowBox[{"(", 
               FractionBox[
                RowBox[{
                 RowBox[{
                  SuperscriptBox["gDss", 
                   FractionBox["1", 
                    RowBox[{"1", "-", "\[Nu]"}]]], " ", "gNss"}], "+", 
                 RowBox[{
                  RowBox[{"(", 
                   RowBox[{
                    RowBox[{"Piess", " ", 
                    RowBox[{"(", 
                    RowBox[{"1", "-", "\[Omega]"}], ")"}]}], "+", 
                    "\[Omega]"}], ")"}], " ", 
                  SubscriptBox["\[Beta]", "1"], " ", 
                  RowBox[{"(", 
                   RowBox[{
                    RowBox[{"-", "1"}], "+", "\[Delta]"}], ")"}]}]}], 
                RowBox[{
                 RowBox[{"(", 
                  RowBox[{
                   RowBox[{"Piess", " ", 
                    RowBox[{"(", 
                    RowBox[{"1", "-", "\[Omega]"}], ")"}]}], "+", 
                   "\[Omega]"}], ")"}], " ", 
                 SubscriptBox["\[Beta]", "1"], " ", "\[Nu]"}]], ")"}], 
              FractionBox["1", 
               RowBox[{
                RowBox[{"-", "1"}], "+", "\[Nu]"}]]]}], ",", 
            RowBox[{"lrconssh", "==", 
             FractionBox[
              RowBox[{"(", 
               RowBox[{
                SuperscriptBox["ktildess", "\[Nu]"], "-", 
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{"gNss", " ", 
                   SuperscriptBox["gDss", 
                    FractionBox["1", 
                    RowBox[{"1", "-", "\[Nu]"}]]], " ", "ktildess"}], "-", 
                  RowBox[{
                   RowBox[{"(", 
                    RowBox[{"1", "-", "\[Delta]"}], ")"}], " ", 
                   "ktildess"}]}], ")"}], "-", 
                RowBox[{"ass", " ", 
                 RowBox[{"(", 
                  RowBox[{"gNss", "-", "Piess"}], " ", ")"}]}]}], ")"}], 
              SuperscriptBox["ktildess", "\[Nu]"]]}], ",", 
            RowBox[{
             SubscriptBox["\[Beta]", "1"], "\[Equal]", 
             RowBox[{"betamax", "*", 
              RowBox[{"(", 
               FractionBox[
                RowBox[{
                 RowBox[{"2", "*", "nTypes"}], "-", "1"}], 
                RowBox[{"2", "*", "nTypes"}]], ")"}]}]}], ",", 
            RowBox[{"betamax", "\[Equal]", 
             FractionBox[
              RowBox[{"1", "-", "\[Alpha]"}], 
              RowBox[{"(", 
               RowBox[{"\[Omega]", "+", 
                RowBox[{
                 RowBox[{"(", 
                  RowBox[{"1", "-", "\[Omega]"}], ")"}], " ", "Piess"}]}], 
               ")"}]]}]}], "}"}], "/.", "inputData"}], ",", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"{", 
            RowBox[{"ass", ",", "0.5"}], "}"}], ",", 
           RowBox[{"{", 
            RowBox[{"ktildess", ",", "0.06"}], "}"}], ",", 
           RowBox[{"{", 
            RowBox[{"\[Alpha]", ",", "0.4"}], "}"}], ",", 
           RowBox[{"{", 
            RowBox[{
             SubscriptBox["\[Beta]", "1"], ",", "0.44"}], "}"}], ",", 
           RowBox[{"{", 
            RowBox[{"betamax", ",", "0.6"}], "}"}]}], "}"}]}], "]"}]}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{"ansss2", "=", 
       RowBox[{"FindRoot", "[", 
        RowBox[{
         RowBox[{
          RowBox[{"{", 
           RowBox[{
            RowBox[{"(", 
             RowBox[{
              RowBox[{"(", 
               RowBox[{
                FractionBox[
                 RowBox[{" ", 
                  RowBox[{"(", 
                   RowBox[{"\[Gamma]", "+", 
                    FractionBox["matchlrirBaselinyears", "25"], "-", "1", "+",
                     "delta"}], ")"}], " "}], 
                 RowBox[{"betamax", 
                  RowBox[{"(", 
                   RowBox[{"1", "+", " ", "\[Gamma]", "+", 
                    FractionBox["matchlrirBaselinyears", "25"], "-", "1"}], 
                   ")"}]}]], 
                FractionBox[
                 RowBox[{
                  SuperscriptBox["gDss", 
                   FractionBox["1", 
                    RowBox[{"1", "-", "\[Nu]"}]]], "gNss"}], 
                 RowBox[{" ", 
                  RowBox[{"(", 
                   RowBox[{"\[Omega]", "+", 
                    RowBox[{
                    RowBox[{"(", 
                    RowBox[{"1", "-", "\[Omega]"}], ")"}], " ", "Piess"}]}], 
                   ")"}]}]]}], ")"}], "\[Equal]", 
              SuperscriptBox[
               RowBox[{"(", 
                RowBox[{"lrintr", "+", "1"}], ")"}], "25.0"]}], ")"}], ",", 
            "\[IndentingNewLine]", 
            RowBox[{"(", 
             RowBox[{
              RowBox[{"(", 
               RowBox[{
                RowBox[{"-", 
                 RowBox[{"(", 
                  RowBox[{
                   RowBox[{"(", 
                    RowBox[{
                    SuperscriptBox["betamax", 
                    RowBox[{"2", "/", "25"}]], " ", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"Pie28", " ", 
                    RowBox[{"(", 
                    RowBox[{"2", "+", 
                    RowBox[{"25", " ", "\[Gamma]"}]}], ")"}], " ", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "\[Omega]"}], ")"}]}], "-", 
                    RowBox[{"Piess", " ", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "23"}], "+", 
                    RowBox[{"25", " ", "delta"}], "+", 
                    RowBox[{"25", " ", "\[Gamma]"}]}], ")"}], " ", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "\[Omega]"}], ")"}]}], "+", 
                    RowBox[{"25", " ", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "delta"}], ")"}], " ", 
                    "\[Omega]"}]}], ")"}], " ", 
                    RowBox[{"gamma", "[", "delta", "]"}], " ", 
                    RowBox[{"gamma", "[", 
                    RowBox[{
                    FractionBox["2", "25"], "+", "\[Gamma]"}], "]"}]}], ")"}],
                    "/", 
                   RowBox[{"(", 
                    RowBox[{"25", " ", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"Pie28", " ", "\[Gamma]"}], "+", 
                    RowBox[{"Piess", " ", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "delta", "+", "\[Gamma]"}], 
                    ")"}], " ", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "\[Omega]"}], ")"}]}], "+", 
                    "\[Omega]", "-", 
                    RowBox[{
                    RowBox[{"(", 
                    RowBox[{"delta", "+", 
                    RowBox[{"Pie28", " ", "\[Gamma]"}]}], ")"}], " ", 
                    "\[Omega]"}]}], ")"}], " ", 
                    RowBox[{"Beta", "[", 
                    RowBox[{"\[Gamma]", ",", "delta"}], "]"}], " ", 
                    RowBox[{"gamma", "[", 
                    RowBox[{
                    FractionBox["2", "25"], "+", "delta", "+", "\[Gamma]"}], 
                    "]"}]}], ")"}]}], ")"}]}], "-", 
                SuperscriptBox[
                 RowBox[{"(", 
                  RowBox[{"-", 
                   RowBox[{"(", 
                    RowBox[{
                    RowBox[{"(", 
                    RowBox[{
                    SuperscriptBox["betamax", 
                    RowBox[{"1", "/", "25"}]], " ", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"Pie28", " ", 
                    RowBox[{"(", 
                    RowBox[{"1", "+", 
                    RowBox[{"25", " ", "\[Gamma]"}]}], ")"}], " ", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "\[Omega]"}], ")"}]}], "-", 
                    RowBox[{"Piess", " ", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "24"}], "+", 
                    RowBox[{"25", " ", "delta"}], "+", 
                    RowBox[{"25", " ", "\[Gamma]"}]}], ")"}], " ", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "\[Omega]"}], ")"}]}], "+", 
                    RowBox[{"25", " ", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "delta"}], ")"}], " ", 
                    "\[Omega]"}]}], ")"}], " ", 
                    RowBox[{"gamma", "[", "delta", "]"}], " ", 
                    RowBox[{"gamma", "[", 
                    RowBox[{
                    FractionBox["1", "25"], "+", "\[Gamma]"}], "]"}]}], ")"}],
                     "/", 
                    RowBox[{"(", 
                    RowBox[{"25", " ", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"Pie28", " ", "\[Gamma]"}], "+", 
                    RowBox[{"Piess", " ", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "delta", "+", "\[Gamma]"}], 
                    ")"}], " ", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "\[Omega]"}], ")"}]}], "+", 
                    "\[Omega]", "-", 
                    RowBox[{
                    RowBox[{"(", 
                    RowBox[{"delta", "+", 
                    RowBox[{"Pie28", " ", "\[Gamma]"}]}], ")"}], " ", 
                    "\[Omega]"}]}], ")"}], " ", 
                    RowBox[{"Beta", "[", 
                    RowBox[{"\[Gamma]", ",", "delta"}], "]"}], " ", 
                    RowBox[{"gamma", "[", 
                    RowBox[{
                    FractionBox["1", "25"], "+", "delta", "+", "\[Gamma]"}], 
                    "]"}]}], ")"}]}], ")"}]}], ")"}], "2"]}], ")"}], 
              "\[Equal]", 
              SuperscriptBox["stdevbeta", "2"]}], ")"}]}], "}"}], "/.", 
          RowBox[{"Join", "[", 
           RowBox[{"ansss1", ",", "inputData"}], "]"}]}], ",", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"{", 
            RowBox[{"\[Gamma]", ",", "36"}], "}"}], ",", 
           RowBox[{"{", 
            RowBox[{"delta", ",", "60"}], "}"}]}], "}"}]}], "]"}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"Return", "[", 
       RowBox[{"Join", "[", 
        RowBox[{"ansss1", ",", "ansss2", ",", "inputData"}], "]"}], "]"}], 
      ";"}]}], "\[IndentingNewLine]", "\[IndentingNewLine]", "]"}]}], 
  ";"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10002.},
 CellChangeTimes->{{3.894944807976871*^9, 3.8949448388836393`*^9}, {
   3.894944874442741*^9, 3.894944885788571*^9}, {3.8949450993706007`*^9, 
   3.8949451279839478`*^9}, {3.8949452511346283`*^9, 3.894945546252459*^9}, 
   3.894945594544979*^9, 3.894947466884184*^9, {3.8967594915355377`*^9, 
   3.896759493215547*^9}, {3.896759881224729*^9, 3.896759896876055*^9}, {
   3.896759992475134*^9, 3.896760015284066*^9}, 3.898765552579307*^9},
 CellLabel->"In[18]:=",ExpressionUUID->"2228675a-62d9-4d58-8f8d-0cae9ab0fc1e"]
}, Closed]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{"calibrationHomo", " ", "-", " ", 
   RowBox[{
   "module", " ", "used", " ", "for", " ", "calibration", " ", "of", " ", 
    "homogenous", " ", "agent", " ", "version", " ", "of", " ", "main", " ", 
    "model"}]}], " ", "*)"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10004.},
 CellChangeTimes->{{3.8949455499060593`*^9, 3.894945550957348*^9}, 
   3.8949455945441713`*^9, 3.894947466883896*^9, 3.898765552579089*^9, {
   3.899783879794277*^9, 3.899783880981864*^9}, {3.899786363314624*^9, 
   3.899786363883141*^9}, {3.899788748568996*^9, 3.8997887588579273`*^9}, {
   3.903068966883892*^9, 3.9030689725991096`*^9}},
 CellLabel->"In[19]:=",ExpressionUUID->"06eacbd9-2999-4625-9d78-d8e28af7cf93"],

Cell[BoxData[
 RowBox[{
  RowBox[{
   RowBox[{"calibrationHomo", "[", "inputData_", "]"}], ":=", 
   "\[IndentingNewLine]", 
   RowBox[{"Module", "[", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{
      "gamma", ",", "ansss1", ",", "ansss2", ",", "allParms", ",", 
       "pointsHomo"}], "}"}], ",", "\[IndentingNewLine]", 
     "\[IndentingNewLine]", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"ansss1", "=", 
       RowBox[{"FindRoot", "[", 
        RowBox[{
         RowBox[{
          RowBox[{"{", 
           RowBox[{
            RowBox[{"gNss", "==", 
             RowBox[{
              RowBox[{"(", 
               RowBox[{
                RowBox[{
                 RowBox[{"-", "ass"}], " ", "Piess", " ", 
                 RowBox[{"(", 
                  RowBox[{
                   RowBox[{"-", "1"}], "+", "\[Alpha]"}], ")"}], " ", 
                 RowBox[{"(", 
                  RowBox[{"1", "+", 
                   RowBox[{"Piess", " ", 
                    SubscriptBox["\[Beta]", "1"], " ", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "\[Omega]"}], ")"}]}], "-", 
                   RowBox[{
                    SubscriptBox["\[Beta]", "1"], " ", "\[Omega]"}]}], 
                  ")"}]}], "+", 
                RowBox[{"ktildess", " ", 
                 RowBox[{"(", 
                  RowBox[{
                   RowBox[{"-", "1"}], "+", "\[Delta]"}], ")"}], " ", 
                 RowBox[{"(", 
                  RowBox[{
                   RowBox[{"-", "1"}], "+", "\[Alpha]", "+", 
                   RowBox[{
                    SubscriptBox["\[Beta]", "1"], " ", 
                    RowBox[{"(", 
                    RowBox[{"Piess", "+", "\[Omega]", "-", 
                    RowBox[{"Piess", " ", "\[Omega]"}]}], ")"}]}]}], ")"}]}], 
                "+", 
                RowBox[{
                 SuperscriptBox["ktildess", "\[Nu]"], " ", 
                 RowBox[{"(", 
                  RowBox[{"1", "-", 
                   RowBox[{"Piess", " ", 
                    SubscriptBox["\[Beta]", "1"]}], "+", 
                   RowBox[{
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "Piess"}], ")"}], " ", 
                    SubscriptBox["\[Beta]", "1"], " ", "\[Omega]"}], "+", 
                   RowBox[{"\[Alpha]", " ", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", 
                    RowBox[{
                    SubscriptBox["\[Beta]", "1"], " ", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "\[Nu]"}], ")"}], " ", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "Piess"}], "+", 
                    RowBox[{
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "Piess"}], ")"}], " ", 
                    "\[Omega]"}]}], ")"}]}]}], ")"}]}]}], ")"}]}]}], ")"}], 
              "/", 
              RowBox[{"(", 
               RowBox[{"ass", "+", 
                RowBox[{"ass", " ", "Piess", " ", 
                 SubscriptBox["\[Beta]", "1"], " ", 
                 RowBox[{"(", 
                  RowBox[{
                   RowBox[{"-", "1"}], "+", "\[Omega]"}], ")"}]}], "-", 
                RowBox[{"ass", " ", 
                 SubscriptBox["\[Beta]", "1"], " ", "\[Omega]"}], "-", 
                RowBox[{
                 SuperscriptBox["gDss", 
                  FractionBox["1", 
                   RowBox[{"1", "-", "\[Nu]"}]]], " ", "ktildess", " ", 
                 RowBox[{"(", 
                  RowBox[{
                   RowBox[{"-", "1"}], "+", "\[Alpha]", "+", 
                   RowBox[{
                    SubscriptBox["\[Beta]", "1"], " ", 
                    RowBox[{"(", 
                    RowBox[{"Piess", "+", "\[Omega]", "-", 
                    RowBox[{"Piess", " ", "\[Omega]"}]}], ")"}]}]}], 
                  ")"}]}]}], ")"}]}]}], ",", 
            RowBox[{"ktildess", "==", 
             SuperscriptBox[
              RowBox[{"(", 
               FractionBox[
                RowBox[{
                 RowBox[{
                  SuperscriptBox["gDss", 
                   FractionBox["1", 
                    RowBox[{"1", "-", "\[Nu]"}]]], " ", "gNss"}], "+", 
                 RowBox[{
                  RowBox[{"(", 
                   RowBox[{
                    RowBox[{"Piess", " ", 
                    RowBox[{"(", 
                    RowBox[{"1", "-", "\[Omega]"}], ")"}]}], "+", 
                    "\[Omega]"}], ")"}], " ", 
                  SubscriptBox["\[Beta]", "1"], " ", 
                  RowBox[{"(", 
                   RowBox[{
                    RowBox[{"-", "1"}], "+", "\[Delta]"}], ")"}]}]}], 
                RowBox[{
                 RowBox[{"(", 
                  RowBox[{
                   RowBox[{"Piess", " ", 
                    RowBox[{"(", 
                    RowBox[{"1", "-", "\[Omega]"}], ")"}]}], "+", 
                   "\[Omega]"}], ")"}], " ", 
                 SubscriptBox["\[Beta]", "1"], " ", "\[Nu]"}]], ")"}], 
              FractionBox["1", 
               RowBox[{
                RowBox[{"-", "1"}], "+", "\[Nu]"}]]]}], ",", 
            RowBox[{"lrconssh", "==", 
             FractionBox[
              RowBox[{"(", 
               RowBox[{
                SuperscriptBox["ktildess", "\[Nu]"], "-", 
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{"gNss", " ", 
                   SuperscriptBox["gDss", 
                    FractionBox["1", 
                    RowBox[{"1", "-", "\[Nu]"}]]], " ", "ktildess"}], "-", 
                  RowBox[{
                   RowBox[{"(", 
                    RowBox[{"1", "-", "\[Delta]"}], ")"}], " ", 
                   "ktildess"}]}], ")"}], "-", 
                RowBox[{"ass", " ", 
                 RowBox[{"(", 
                  RowBox[{"gNss", "-", "Piess"}], " ", ")"}]}]}], ")"}], 
              SuperscriptBox["ktildess", "\[Nu]"]]}], ",", 
            RowBox[{
             SubscriptBox["\[Beta]", "1"], "\[Equal]", "ave\[Beta]"}]}], 
           "}"}], "/.", "inputData"}], ",", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"{", 
            RowBox[{"ass", ",", "0.35"}], "}"}], ",", 
           RowBox[{"{", 
            RowBox[{"ktildess", ",", "0.06"}], "}"}], ",", 
           RowBox[{"{", 
            RowBox[{"\[Alpha]", ",", "0.4"}], "}"}], ",", 
           RowBox[{"{", 
            RowBox[{
             SubscriptBox["\[Beta]", "1"], ",", "0.44"}], "}"}]}], "}"}]}], 
        "]"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"allParms", "=", 
       RowBox[{"Join", "[", 
        RowBox[{"ansss1", ",", "inputData"}], "]"}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"pointsHomo", "=", 
       RowBox[{"{", 
        RowBox[{
         RowBox[{"inityear", "\[Rule]", 
          RowBox[{"(", 
           RowBox[{"inityear", "/.", "allParms"}], ")"}]}], ",", 
         RowBox[{"currentyear", "\[Rule]", 
          RowBox[{"(", 
           RowBox[{"currentyear", "/.", "allParms"}], ")"}]}], ",", 
         RowBox[{"\[Delta]", "\[Rule]", 
          RowBox[{"(", 
           RowBox[{"\[Delta]", "/.", "allParms"}], ")"}]}], ",", 
         RowBox[{"eNdata", "\[Rule]", 
          RowBox[{
           RowBox[{"(", 
            RowBox[{"Nm1parm", "/.", "allParms"}], ")"}], "*", 
           RowBox[{
            RowBox[{"smoothedLevelsFromGrowth", "[", 
             RowBox[{
              RowBox[{"(", 
               RowBox[{"gNCutoffs", "/.", "inputData"}], ")"}], ",", 
              RowBox[{
               RowBox[{"(", 
                RowBox[{"inityear", "/.", "inputData"}], ")"}], "-", "25"}], 
              ",", 
              RowBox[{
               RowBox[{"(", 
                RowBox[{"currentyear", "+", "gNyearsFuture"}], ")"}], "/.", 
               "inputData"}]}], "]"}], "[", 
            RowBox[{"[", 
             RowBox[{"All", ",", "2"}], "]"}], "]"}]}]}], ",", 
         RowBox[{"gNss", "\[Rule]", 
          RowBox[{"(", 
           RowBox[{"gNss", "/.", "allParms"}], ")"}]}], ",", 
         RowBox[{"Dee", "\[Rule]", 
          RowBox[{
           RowBox[{"smoothedLevelsFromGrowth", "[", 
            RowBox[{
             RowBox[{"(", 
              RowBox[{"gDCutoffs", "/.", "inputData"}], ")"}], ",", 
             RowBox[{
              RowBox[{"(", 
               RowBox[{"inityear", "/.", "inputData"}], ")"}], "-", "25"}], 
             ",", 
             RowBox[{
              RowBox[{"(", 
               RowBox[{"currentyear", "+", "gDyearsFuture"}], ")"}], "/.", 
              "inputData"}]}], "]"}], "[", 
           RowBox[{"[", 
            RowBox[{"All", ",", "2"}], "]"}], "]"}]}], ",", 
         RowBox[{"grDee", "\[Rule]", 
          RowBox[{"(", 
           RowBox[{"gDss", "/.", "allParms"}], ")"}]}], ",", 
         RowBox[{"\[Nu]", "\[Rule]", 
          RowBox[{"(", 
           RowBox[{"\[Nu]", "/.", "allParms"}], ")"}]}], ",", 
         RowBox[{"\[Alpha]", "\[Rule]", 
          RowBox[{"(", 
           RowBox[{"\[Alpha]", "/.", "allParms"}], ")"}]}], ",", 
         RowBox[{"Pie", "\[Rule]", 
          RowBox[{"(", 
           RowBox[{"Pie", "/.", "allParms"}], ")"}]}], ",", 
         RowBox[{"Piess", "\[Rule]", 
          RowBox[{"(", 
           RowBox[{"Piess", "/.", "allParms"}], ")"}]}], ",", 
         RowBox[{"\[Omega]", "\[Rule]", 
          RowBox[{"(", 
           RowBox[{"\[Omega]", "/.", "allParms"}], ")"}]}], ",", 
         RowBox[{"time", "\[Rule]", 
          RowBox[{"(", 
           RowBox[{"time", "/.", "allParms"}], ")"}]}], ",", 
         RowBox[{"\[Beta]", "\[Rule]", 
          RowBox[{"{", 
           RowBox[{"(", 
            RowBox[{"ave\[Beta]", "/.", "allParms"}], ")"}], "}"}]}], ",", 
         RowBox[{"propN", "\[Rule]", 
          RowBox[{"{", "1", "}"}]}], ",", 
         RowBox[{
          SubscriptBox["ktilde", 
           RowBox[{"-", "1"}]], "\[Rule]", 
          SubscriptBox["ktilde", "0"]}], ",", 
         RowBox[{"precision", "\[Rule]", 
          RowBox[{"(", 
           RowBox[{"precision", "/.", "allParms"}], ")"}]}], ",", 
         RowBox[{"percentiles", "\[Rule]", 
          RowBox[{"(", 
           RowBox[{"percentiles", "/.", "allParms"}], ")"}]}]}], "}"}]}], ";",
       "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"Return", "[", 
       RowBox[{"{", 
        RowBox[{
         RowBox[{"Join", "[", 
          RowBox[{"ansss1", ",", "inputData"}], "]"}], ",", "pointsHomo"}], 
        "}"}], "]"}], ";"}]}], "\[IndentingNewLine]", "\[IndentingNewLine]", 
    "]"}]}], ";"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10004.},
 CellChangeTimes->{{3.894944807976871*^9, 3.8949448388836393`*^9}, {
   3.894944874442741*^9, 3.894944885788571*^9}, {3.8949450993706007`*^9, 
   3.8949451279839478`*^9}, {3.8949452511346283`*^9, 3.894945546252459*^9}, 
   3.894945594544979*^9, 3.894947466884184*^9, {3.8967594915355377`*^9, 
   3.896759493215547*^9}, {3.896759881224729*^9, 3.896759896876055*^9}, {
   3.896759992475134*^9, 3.896760015284066*^9}, 3.898765552579307*^9, {
   3.8997838848133802`*^9, 3.8997838852129297`*^9}, {3.8997839207274437`*^9, 
   3.899783922996584*^9}, {3.899783992280843*^9, 3.8997840200927877`*^9}, {
   3.899784395515875*^9, 3.8997844722410192`*^9}, 3.8997887588582163`*^9, {
   3.902981744399949*^9, 3.902981770499899*^9}},
 CellLabel->"In[20]:=",ExpressionUUID->"3d5ea2ce-3745-4601-affd-ffbe66dfc57c"]
}, Closed]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{
   RowBox[{
    RowBox[{"calibrateFixedCapital", "[", "]"}], " ", "--"}], " ", 
   "Calibrates", " ", "the", " ", "Fixed", " ", "capital", " ", "model", " ", 
   "and", " ", "the", " ", "corresponding", " ", "homogenous", " ", "model", 
   " ", "and", " ", "returns", " ", "the", " ", "starting", " ", "points", 
   " ", "used", " ", "to", " ", "solve", " ", "the", " ", "models", " ", 
   "with", " ", "the", " ", "module", " ", "SolveModelFixedCapital"}], 
  "*)"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.},
 CellChangeTimes->{{3.902906202092149*^9, 3.902906245170244*^9}, {
  3.902906691641121*^9, 3.902906711787917*^9}},
 CellLabel->"In[21]:=",ExpressionUUID->"010898c2-81bd-4540-b2db-cdbe621ef814"],

Cell[BoxData[
 RowBox[{
  RowBox[{
   RowBox[{"calibrateFixedCapital", "[", "]"}], ":=", 
   RowBox[{"Module", "[", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{
      "pathBaseline", ",", "nTypesparm", ",", "timeparm", ",", "inityearparm",
        ",", "currentyearparm", ",", "percentilesparm", ",", "pop", ",", 
       "N0parm", ",", "Ncyparm", ",", "Deeparm", ",", "\[Nu]parm", ",", 
       "Pieparm", ",", "lrconssh", ",", "lrintr", ",", "stdevDenmark", ",", 
       "temp", ",", "worldSd", ",", "stdevbeta", ",", "precisionparm", ",", 
       "betaminparm", ",", "\[Gamma]parm", ",", "\[Delta]parm", ",", 
       "distt2000", ",", "initialDistribution", ",", "meanbeta2000", ",", 
       "points", ",", "pointsHomo", ",", "\[Alpha]parm"}], "}"}], ",", 
     "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
     "\[IndentingNewLine]", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"nTypesparm", "=", "10000"}], ";", "\[IndentingNewLine]", 
      RowBox[{"timeparm", "=", "200"}], ";", "\[IndentingNewLine]", 
      RowBox[{"inityearparm", "=", "1300"}], ";", "\[IndentingNewLine]", 
      RowBox[{"currentyearparm", "=", "2000"}], ";", "\[IndentingNewLine]", 
      RowBox[{"percentilesparm", "=", "8"}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"pop", "=", 
       RowBox[{
        RowBox[{"Rest", "[", 
         RowBox[{"Import", "[", 
          RowBox[{"path", "<>", "\"\<Outputs/Data/maddison_pop.csv\>\""}], 
          "]"}], "]"}], "[", 
        RowBox[{"[", 
         RowBox[{"All", ",", "2"}], "]"}], "]"}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"N0parm", "=", 
       RowBox[{"pop", "[", 
        RowBox[{"[", "inityearparm", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", 
       RowBox[{
       "Matches", " ", "world", " ", "population", " ", "in", " ", 
        "inityearparm"}], "*)"}], "\[IndentingNewLine]", 
      RowBox[{"Ncyparm", "=", 
       RowBox[{"pop", "[", 
        RowBox[{"[", "currentyearparm", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", 
       RowBox[{
       "Matches", " ", "world", " ", "population", " ", "in", " ", 
        "currentyearparm"}], "*)"}], "\[IndentingNewLine]", 
      RowBox[{"Deeparm", "=", "1"}], ";", "\[IndentingNewLine]", 
      RowBox[{"\[Nu]parm", "=", "0.19"}], ";", "\[IndentingNewLine]", 
      RowBox[{"Pieparm", "=", "0.66667"}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"lrconssh", "=", 
       RowBox[{"Round", "[", 
        RowBox[{
         RowBox[{
          RowBox[{"Import", "[", 
           RowBox[{
            RowBox[{"path", "<>", "\"\<Outputs/Tables/lrconsshare.txt\>\""}], 
            ",", "\"\<Table\>\""}], "]"}], "[", 
          RowBox[{"[", 
           RowBox[{"2", ",", "2"}], "]"}], "]"}], ",", "0.01"}], "]"}]}], ";",
       "\[IndentingNewLine]", 
      RowBox[{"lrintr", "=", 
       RowBox[{"Round", "[", 
        RowBox[{
         RowBox[{
          RowBox[{"Import", "[", 
           RowBox[{
            RowBox[{
            "path", "<>", "\"\<Outputs/Tables/lrinterestrate.txt\>\""}], ",", 
            "\"\<Table\>\""}], "]"}], "[", 
          RowBox[{"[", 
           RowBox[{"2", ",", "2"}], "]"}], "]"}], ",", "0.001"}], "]"}]}], 
      ";", "\[IndentingNewLine]", 
      RowBox[{"stdevDenmark", "=", "0.00659957"}], ";", "\[IndentingNewLine]",
       "\[IndentingNewLine]", 
      RowBox[{"temp", "=", 
       RowBox[{"Import", "[", 
        RowBox[{"path", "<>", "\"\<Outputs/Data/sdByCountry.csv\>\""}], 
        "]"}]}], ";", "\[IndentingNewLine]", 
      RowBox[{"worldSd", "=", 
       RowBox[{"WeightedData", "[", 
        RowBox[{
         RowBox[{"Rest", "[", 
          RowBox[{"temp", "[", 
           RowBox[{"[", 
            RowBox[{"All", ",", "4"}], "]"}], "]"}], "]"}], ",", 
         RowBox[{"Rest", "[", 
          RowBox[{"temp", "[", 
           RowBox[{"[", 
            RowBox[{"All", ",", "5"}], "]"}], "]"}], "]"}]}], "]"}]}], ";", 
      RowBox[{"Clear", "[", "temp", "]"}], ";", "\[IndentingNewLine]", 
      RowBox[{"(*", 
       RowBox[{
        RowBox[{"stdevbeta", "=", 
         RowBox[{"Round", "[", 
          RowBox[{
           RowBox[{"Mean", "[", "worldSd", "]"}], ",", "0.0001"}], "]"}]}], 
        ";"}], "*)"}], "\[IndentingNewLine]", 
      RowBox[{"stdevbeta", "=", 
       RowBox[{"Round", "[", 
        RowBox[{
         RowBox[{"Median", "[", "worldSd", "]"}], ",", "0.0001"}], "]"}]}], 
      ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"precisionparm", "=", "100"}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"betaminparm", "=", "0"}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"temp", "=", 
       RowBox[{
        RowBox[{"Quiet", "[", 
         RowBox[{
          RowBox[{"Solve", "[", 
           RowBox[{
            RowBox[{"{", 
             RowBox[{
              RowBox[{"lrconssh", "\[Equal]", 
               FractionBox[
                RowBox[{"\[Alpha]", "*", 
                 RowBox[{"(", 
                  RowBox[{"1", "-", 
                   RowBox[{"betaI", "*", 
                    RowBox[{"(", 
                    RowBox[{"1", "-", 
                    RowBox[{"\[Nu]parm", "*", 
                    RowBox[{"(", 
                    RowBox[{"1", "-", "Pieparm"}], ")"}]}]}], ")"}]}]}], 
                  ")"}]}], 
                RowBox[{
                 RowBox[{"(", 
                  RowBox[{"1", "-", 
                   RowBox[{"Pieparm", "*", 
                    RowBox[{"(", 
                    RowBox[{"1", "-", "\[Alpha]"}], ")"}]}]}], ")"}], "*", 
                 RowBox[{"(", 
                  RowBox[{"1", "-", "betaI"}], ")"}]}]]}], ",", 
              RowBox[{"betaI", "\[Equal]", 
               RowBox[{"betamax", "*", 
                RowBox[{"(", 
                 FractionBox[
                  RowBox[{
                   RowBox[{"2", "*", "nTypesparm"}], "-", "1"}], 
                  RowBox[{"2", "*", "nTypesparm"}]], ")"}]}]}], ",", 
              RowBox[{"betamax", "\[Equal]", 
               RowBox[{"1", "-", "\[Alpha]"}]}], ",", 
              RowBox[{"\[Alpha]", ">", "0"}], ",", 
              RowBox[{"betaI", "<", "1"}], ",", 
              RowBox[{"betamax", "<", "1"}], ",", 
              RowBox[{"betaI", "<", "betamax"}]}], "}"}], ",", 
            RowBox[{"{", 
             RowBox[{"\[Alpha]", ",", "betaI", ",", "betamax"}], "}"}]}], 
           "]"}], "[", 
          RowBox[{"[", "1", "]"}], "]"}], "]"}], "[", 
        RowBox[{"[", 
         RowBox[{"All", ",", "2"}], "]"}], "]"}]}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{"\[Alpha]parm", "=", 
       RowBox[{"temp", "[", 
        RowBox[{"[", "1", "]"}], "]"}]}], ";", 
      RowBox[{"betamaxparm", "=", 
       RowBox[{"temp", "[", 
        RowBox[{"[", "3", "]"}], "]"}]}], ";", 
      RowBox[{"Clear", "[", "temp", "]"}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"temp", "=", 
       RowBox[{
        RowBox[{"Quiet", "[", 
         RowBox[{"FindRoot", "[", 
          RowBox[{
           RowBox[{"{", 
            RowBox[{
             RowBox[{
              RowBox[{
               SuperscriptBox[
                RowBox[{"(", 
                 FractionBox[
                  RowBox[{"\[Gamma]", "-", "1", "+", "\[Delta]"}], 
                  RowBox[{"betamaxparm", " ", 
                   RowBox[{"(", 
                    RowBox[{"1", "+", "\[Gamma]", "-", "1"}], ")"}]}]], ")"}], 
                FractionBox["1", "25"]], "-", "1"}], "\[Equal]", "lrintr"}], 
             ",", "\[IndentingNewLine]", 
             RowBox[{
              RowBox[{
               SuperscriptBox["betamaxparm", 
                RowBox[{"2", "/", "25"}]], "*", 
               RowBox[{"(", 
                RowBox[{
                 SuperscriptBox["E", 
                  RowBox[{
                   RowBox[{"LogGamma", "[", 
                    RowBox[{
                    FractionBox["2", "25.0"], "+", "\[Gamma]"}], "]"}], "+", 
                   RowBox[{"LogGamma", "[", 
                    RowBox[{"1.0", "*", "\[Gamma]"}], "]"}], "-", 
                   RowBox[{"LogGamma", "[", 
                    RowBox[{
                    FractionBox["2", "25.0"], "+", "\[Gamma]", "+", 
                    "\[Delta]"}], "]"}], "-", 
                   RowBox[{"2.0", "*", 
                    RowBox[{"LogGamma", "[", 
                    RowBox[{"1.0", "*", "\[Gamma]"}], "]"}]}], "+", 
                   RowBox[{"LogGamma", "[", 
                    RowBox[{"\[Gamma]", "+", "\[Delta]"}], "]"}]}]], "-", 
                 SuperscriptBox["E", 
                  RowBox[{
                   RowBox[{"2.0", "*", 
                    RowBox[{"LogGamma", "[", 
                    RowBox[{
                    FractionBox["1", "25.0"], "+", "\[Gamma]"}], "]"}]}], "+", 
                   RowBox[{"LogGamma", "[", 
                    RowBox[{
                    RowBox[{"1.0", "*", "\[Gamma]"}], "+", "\[Delta]"}], 
                    "]"}], "-", 
                   RowBox[{"2.0", "*", 
                    RowBox[{"LogGamma", "[", 
                    RowBox[{
                    FractionBox["1", "25.0"], "+", "\[Gamma]", "+", 
                    "\[Delta]"}], "]"}]}], "-", 
                   RowBox[{"2.0", "*", 
                    RowBox[{"LogGamma", "[", 
                    RowBox[{"1.0", "*", "\[Gamma]"}], "]"}]}], "+", 
                   RowBox[{"LogGamma", "[", 
                    RowBox[{"\[Gamma]", "+", "\[Delta]"}], "]"}]}]]}], 
                ")"}]}], "\[IndentingNewLine]", "\[Equal]", 
              SuperscriptBox["stdevbeta", "2"]}]}], "}"}], ",", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"{", 
              RowBox[{"\[Gamma]", ",", "38"}], "}"}], ",", 
             RowBox[{"{", 
              RowBox[{"\[Delta]", ",", "46"}], "}"}]}], "}"}]}], "]"}], "]"}],
         "[", 
        RowBox[{"[", 
         RowBox[{"All", ",", "2"}], "]"}], "]"}]}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{"\[Gamma]parm", "=", 
       RowBox[{"temp", "[", 
        RowBox[{"[", "1", "]"}], "]"}]}], ";", 
      RowBox[{"\[Delta]parm", "=", 
       RowBox[{"temp", "[", 
        RowBox[{"[", "2", "]"}], "]"}]}], ";", 
      RowBox[{"Clear", "[", "temp", "]"}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"distt2000", "=", 
       RowBox[{"genBetaDistribution2", "[", 
        RowBox[{
        "betaminparm", ",", "betamaxparm", ",", "\[Gamma]parm", ",", 
         "\[Delta]parm", ",", "nTypesparm", ",", "precisionparm"}], "]"}]}], 
      ";", "\[IndentingNewLine]", 
      RowBox[{"initialDistribution", "=", 
       RowBox[{"findInitialDistribution", "[", 
        RowBox[{"distt2000", ",", "currentyearparm", ",", "inityearparm"}], 
        "]"}]}], ";", "\[IndentingNewLine]", 
      RowBox[{"meanbeta2000", "=", 
       RowBox[{"Total", "[", 
        RowBox[{
         RowBox[{"distt2000", "[", 
          RowBox[{"[", 
           RowBox[{"All", ",", "2"}], "]"}], "]"}], "*", 
         RowBox[{"distt2000", "[", 
          RowBox[{"[", 
           RowBox[{"All", ",", "1"}], "]"}], "]"}]}], "]"}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"points", "=", 
       RowBox[{"{", 
        RowBox[{
         RowBox[{"inityear", "\[Rule]", "inityearparm"}], ",", 
         RowBox[{"currentyear", "\[Rule]", "currentyearparm"}], ",", 
         RowBox[{"N0", "\[Rule]", "N0parm"}], ",", 
         RowBox[{"Ncy", "\[Rule]", "Ncyparm"}], ",", 
         RowBox[{"Dee", "\[Rule]", "Deeparm"}], ",", 
         RowBox[{"\[Nu]", "\[Rule]", "\[Nu]parm"}], ",", 
         RowBox[{"\[Alpha]", "\[Rule]", "\[Alpha]parm"}], ",", 
         RowBox[{"Pie", "\[Rule]", "Pieparm"}], ",", 
         RowBox[{"time", "\[Rule]", "timeparm"}], ",", 
         RowBox[{"\[Beta]", "\[Rule]", 
          RowBox[{"initialDistribution", "[", 
           RowBox[{"[", 
            RowBox[{"All", ",", "1"}], "]"}], "]"}]}], ",", 
         RowBox[{"propN", "\[Rule]", 
          RowBox[{"initialDistribution", "[", 
           RowBox[{"[", 
            RowBox[{"All", ",", "2"}], "]"}], "]"}]}], ",", 
         RowBox[{"precision", "\[Rule]", "precisionparm"}], ",", 
         RowBox[{"percentiles", "\[Rule]", "percentilesparm"}]}], "}"}]}], 
      ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"temp", "=", 
       RowBox[{
        RowBox[{"Quiet", "[", 
         RowBox[{
          RowBox[{"Solve", "[", 
           RowBox[{
            RowBox[{"{", 
             RowBox[{
              RowBox[{"lrconssh", "\[Equal]", 
               FractionBox[
                RowBox[{"\[Alpha]", "*", 
                 RowBox[{"(", 
                  RowBox[{"1", "-", 
                   RowBox[{"betaI", "*", 
                    RowBox[{"(", 
                    RowBox[{"1", "-", 
                    RowBox[{"\[Nu]parm", "*", 
                    RowBox[{"(", 
                    RowBox[{"1", "-", "Pieparm"}], ")"}]}]}], ")"}]}]}], 
                  ")"}]}], 
                RowBox[{
                 RowBox[{"(", 
                  RowBox[{"1", "-", 
                   RowBox[{"Pieparm", "*", 
                    RowBox[{"(", 
                    RowBox[{"1", "-", "\[Alpha]"}], ")"}]}]}], ")"}], "*", 
                 RowBox[{"(", 
                  RowBox[{"1", "-", "betaI"}], ")"}]}]]}], ",", 
              RowBox[{"betaI", "\[Equal]", "meanbeta2000"}], ",", 
              RowBox[{"\[Alpha]", ">", "0"}], ",", 
              RowBox[{"betaI", "<", "1"}]}], "}"}], ",", 
            RowBox[{"{", 
             RowBox[{"\[Alpha]", ",", "betaI"}], "}"}]}], "]"}], "[", 
          RowBox[{"[", "1", "]"}], "]"}], "]"}], "[", 
        RowBox[{"[", 
         RowBox[{"All", ",", "2"}], "]"}], "]"}]}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{"\[Alpha]parm", "=", 
       RowBox[{"temp", "[", 
        RowBox[{"[", "1", "]"}], "]"}]}], ";", 
      RowBox[{"Clear", "[", "temp", "]"}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"pointsHomo", "=", 
       RowBox[{"{", 
        RowBox[{
         RowBox[{"inityear", "\[Rule]", "inityearparm"}], ",", 
         RowBox[{"currentyear", "\[Rule]", "currentyearparm"}], ",", 
         RowBox[{"N0", "\[Rule]", "N0parm"}], ",", 
         RowBox[{"Ncy", "\[Rule]", "Ncyparm"}], ",", 
         RowBox[{"Dee", "\[Rule]", "Deeparm"}], ",", 
         RowBox[{"\[Nu]", "\[Rule]", "\[Nu]parm"}], ",", 
         RowBox[{"\[Alpha]", "\[Rule]", "\[Alpha]parm"}], ",", 
         RowBox[{"Pie", "\[Rule]", "Pieparm"}], ",", 
         RowBox[{"time", "\[Rule]", "timeparm"}], ",", 
         RowBox[{"\[Beta]", "\[Rule]", 
          RowBox[{"{", "meanbeta2000", "}"}]}], ",", 
         RowBox[{"propN", "\[Rule]", 
          RowBox[{"{", "1", "}"}]}], ",", 
         RowBox[{"precision", "\[Rule]", "precisionparm"}], ",", 
         RowBox[{"percentiles", "\[Rule]", "percentilesparm"}]}], "}"}]}], 
      ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"{", 
       RowBox[{"points", ",", "pointsHomo"}], "}"}]}]}], 
    "\[IndentingNewLine]", "\[IndentingNewLine]", "]"}]}], "\n"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.},
 CellChangeTimes->{{3.90290556717253*^9, 3.902905612659115*^9}, {
   3.90290570817768*^9, 3.902905724125503*^9}, {3.90290575826853*^9, 
   3.90290576952487*^9}, 3.9029062451709948`*^9, {3.902906333367943*^9, 
   3.902906370413535*^9}, {3.902906719449553*^9, 3.902906721093397*^9}, {
   3.9029758232370872`*^9, 3.9029758239482527`*^9}, {3.902976067943736*^9, 
   3.902976080257188*^9}, {3.902976360015044*^9, 3.9029763698554487`*^9}, {
   3.903000707571931*^9, 3.903000711271125*^9}, 3.9030008490386*^9},
 CellLabel->"In[22]:=",ExpressionUUID->"14e88dc4-3e24-47b4-baf1-ff642985e626"]
}, Closed]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{
   RowBox[{"genBetaDistribution2", " ", "-", " ", 
    RowBox[{
    "Generate", " ", "an", " ", "approximate", " ", "discrete", " ", "Beta", 
     " ", "Distribution"}]}], ",", " ", 
   RowBox[{"from", " ", "generational", " ", "data"}]}], "*)"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10003.},
 CellChangeTimes->{{3.7730627919321585`*^9, 3.773062814817148*^9}, 
   3.7749540786887054`*^9, {3.774954144554533*^9, 3.7749541502025156`*^9}, 
   3.898765523484254*^9},
 CellLabel->"In[23]:=",ExpressionUUID->"ff851ad5-70ed-4bb3-b111-07609c9c3808"],

Cell[BoxData[
 RowBox[{
  RowBox[{
   RowBox[{"genBetaDistribution2", "[", 
    RowBox[{
    "betaminx_", ",", "betamaxx_", ",", "\[Gamma]x_", ",", "\[Delta]x_", ",", 
     "nTypesx_", ",", "precisionx_"}], "]"}], ":=", 
   RowBox[{
    RowBox[{"genBetaDistribution2", "[", 
     RowBox[{
     "betaminx", ",", "betamaxx", ",", "\[Gamma]x", ",", "\[Delta]x", ",", 
      "nTypesx", ",", "precisionx"}], "]"}], "=", "\[IndentingNewLine]", 
    RowBox[{"Module", "[", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{
        RowBox[{"betamin", "=", "betaminx"}], ",", 
        RowBox[{"betamax", "=", "betamaxx"}], ",", 
        RowBox[{"\[Gamma]", "=", "\[Gamma]x"}], ",", 
        RowBox[{"\[Delta]", "=", "\[Delta]x"}], ",", 
        RowBox[{"nTypes", "=", "nTypesx"}], ",", 
        RowBox[{"precision", "=", "precisionx"}], ",", "\[IndentingNewLine]", 
        "F", ",", "distdelta", ",", "distx", ",", "distBoundries", ",", 
        "distxAn", ",", "distBoundriesAn", ",", "disttans", ",", "r", ",", 
        "CF", ",", "betaReg"}], "}"}], ",", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"(*", 
       RowBox[{
       "This", " ", "calculates", " ", "the", " ", "necessary", " ", "CDF", 
        " ", "from", " ", "the", " ", "BetaRegularized", " ", "function", " ",
         "directly"}], "*)"}], "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{
        RowBox[{"F", "[", "z_", "]"}], ":=", 
        RowBox[{
         RowBox[{"F", "[", "z", "]"}], "=", 
         RowBox[{"BetaRegularized", "[", 
          RowBox[{
           RowBox[{"SetPrecision", "[", 
            RowBox[{
             FractionBox["z", "betamax"], ",", "precision"}], "]"}], ",", 
           RowBox[{"SetPrecision", "[", 
            RowBox[{"\[Gamma]", ",", "precision"}], "]"}], ",", 
           RowBox[{"SetPrecision", "[", 
            RowBox[{"\[Delta]", ",", "precision"}], "]"}]}], "]"}]}]}], ";", 
       "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
       "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
       "\[IndentingNewLine]", 
       RowBox[{"distdelta", "=", 
        FractionBox[
         RowBox[{
          RowBox[{"SetPrecision", "[", 
           RowBox[{"betamax", ",", "precision"}], "]"}], "-", 
          RowBox[{"SetPrecision", "[", 
           RowBox[{"betamin", ",", "precision"}], "]"}]}], 
         RowBox[{"SetPrecision", "[", 
          RowBox[{"nTypes", ",", "precision"}], "]"}]]}], ";", " ", 
       RowBox[{"(*", 
        RowBox[{
        "Width", " ", "of", " ", "bins", " ", "I", " ", "am", " ", "chopping",
          " ", "my", " ", "beta", " ", "space", " ", "into"}], "*)"}], 
       "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"distBoundries", "[", "i_", "]"}], ":=", 
        RowBox[{
         RowBox[{"distBoundries", "[", "i", "]"}], "=", 
         RowBox[{"betamin", "+", 
          RowBox[{"distdelta", "*", "i"}]}]}]}], ";", "\[IndentingNewLine]", 
       "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{"disttans", "=", 
        RowBox[{"Reverse", "[", 
         RowBox[{"Table", "[", 
          RowBox[{
           RowBox[{"{", 
            RowBox[{
             RowBox[{"betamin", "+", 
              FractionBox["distdelta", "2.0"], "+", 
              RowBox[{"distdelta", "*", 
               RowBox[{"(", 
                RowBox[{"i", "-", "1"}], ")"}]}]}], ",", 
             RowBox[{
              RowBox[{"F", "[", 
               RowBox[{"distBoundries", "[", "i", "]"}], "]"}], "-", 
              RowBox[{"F", "[", 
               RowBox[{"distBoundries", "[", 
                RowBox[{"i", "-", "1"}], "]"}], "]"}]}]}], "}"}], ",", 
           RowBox[{"{", 
            RowBox[{"i", ",", "1", ",", "nTypes"}], "}"}]}], "]"}], "]"}]}], 
       ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
       "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{"Return", "[", "disttans", "]"}], ";"}]}], 
     "\[IndentingNewLine]", "\[IndentingNewLine]", "]"}]}]}], ";"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10003.},
 CellChangeTimes->{{3.773062577911236*^9, 3.773062784092641*^9}, 
   3.773062814817148*^9, {3.7749540786887054`*^9, 3.774954120893468*^9}, {
   3.774956502810003*^9, 3.7749565184001274`*^9}, 3.774957460415444*^9, {
   3.7749576281199007`*^9, 3.774957640896598*^9}, {3.774957707727748*^9, 
   3.774957756563464*^9}, {3.7749578442989683`*^9, 3.77495784917144*^9}, {
   3.7753736628586197`*^9, 3.7753736689542456`*^9}, {3.7764121493648863`*^9, 
   3.7764121496031294`*^9}, {3.776414276934291*^9, 3.776414297924225*^9}, {
   3.7764154293236923`*^9, 3.7764154579809046`*^9}, {3.7764160302288294`*^9, 
   3.7764160329787188`*^9}, {3.791738405276246*^9, 3.791738422973917*^9}, {
   3.7917384558275414`*^9, 3.7917385022430124`*^9}, {3.7917389593525267`*^9, 
   3.7917389677117553`*^9}, {3.791740641364012*^9, 3.791740655758849*^9}, {
   3.791741040761851*^9, 3.7917410454807563`*^9}, {3.791741415103448*^9, 
   3.791741417683938*^9}, {3.7917417232621803`*^9, 3.791741727755599*^9}, {
   3.7917419565438256`*^9, 3.7917419725885305`*^9}, {3.791743124247658*^9, 
   3.791743129460141*^9}, {3.7917434830215178`*^9, 3.791743568108313*^9}, {
   3.7930154646290207`*^9, 3.7930154727515583`*^9}, 3.898765523484497*^9, {
   3.903068997940784*^9, 3.903069003370461*^9}},
 CellLabel->"In[24]:=",ExpressionUUID->"1ca0154b-43da-46c6-a7e4-599e81af62e8"]
}, Closed]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{"findInitialDistribution", " ", "-", " ", 
   RowBox[{
   "Find", " ", "initial", " ", "Distribution", " ", "of", " ", "types", " ", 
    "given", " ", "some", " ", "future", " ", "distribution"}]}], 
  "*)"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10002.},
 CellChangeTimes->{{3.7730604660253496`*^9, 3.773060495031698*^9}, 
   3.8518460626313715`*^9, {3.8629767398655753`*^9, 3.862976745690205*^9}, {
   3.902726258675578*^9, 3.902726259451395*^9}},
 CellLabel->"In[25]:=",ExpressionUUID->"7fa14643-0c6a-4567-ae31-85379b2e62eb"],

Cell[BoxData[
 RowBox[{
  RowBox[{
   RowBox[{"findInitialDistribution", "[", 
    RowBox[{"distributionTodayx_", ",", "yearTodayx_", ",", "yearInitialx_"}],
     "]"}], ":=", 
   RowBox[{
    RowBox[{"findInitialDistribution", "[", 
     RowBox[{"distributionTodayx", ",", "yearTodayx", ",", "yearInitialx"}], 
     "]"}], "=", "\[IndentingNewLine]", 
    RowBox[{"Module", "[", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{
        RowBox[{"distributionToday", "=", "distributionTodayx"}], ",", 
        RowBox[{"yearToday", "=", "yearTodayx"}], ",", 
        RowBox[{"yearInitial", "=", "yearInitialx"}], ",", 
        "\[IndentingNewLine]", "numberGenerations", ",", 
        "reldistributionToday", ",", "s", ",", "rels", ",", "nTypes", ",", 
        "propans", ",", "initialDistribution"}], "}"}], ",", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"numberGenerations", "=", 
        FractionBox[
         RowBox[{"yearToday", "-", "yearInitial"}], "25"]}], ";", 
       "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{"reldistributionToday", "=", "distributionToday"}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"reldistributionToday", "[", 
         RowBox[{"[", 
          RowBox[{"All", ",", "2"}], "]"}], "]"}], "=", 
        FractionBox[
         RowBox[{"distributionToday", "[", 
          RowBox[{"[", 
           RowBox[{"All", ",", "2"}], "]"}], "]"}], 
         RowBox[{
          RowBox[{"distributionToday", "[", 
           RowBox[{"[", 
            RowBox[{"All", ",", "2"}], "]"}], "]"}], "[", 
          RowBox[{"[", "1", "]"}], "]"}]]}], ";", " ", "\[IndentingNewLine]", 
       RowBox[{"nTypes", "=", 
        RowBox[{"Length", "[", "distributionToday", "]"}]}], ";", 
       "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
       "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"s", "[", 
         RowBox[{"i_", ",", "t_"}], "]"}], ":=", 
        FractionBox[
         RowBox[{
          SubscriptBox["propN", "i"], " ", 
          SuperscriptBox[
           SubscriptBox["\[Beta]", "i"], "t"]}], 
         RowBox[{
          UnderoverscriptBox["\[Sum]", 
           RowBox[{"j", "=", "1"}], "nTypes"], 
          RowBox[{
           SubscriptBox["propN", "j"], " ", 
           SuperscriptBox[
            SubscriptBox["\[Beta]", "j"], "t"]}]}]]}], ";", " ", 
       RowBox[{"(*", 
        RowBox[{
        "The", " ", "share", " ", "of", " ", "each", " ", "type", " ", "of", 
         " ", "agent", " ", "at", " ", "any", " ", "given", " ", 
         RowBox[{"time", "."}]}], " ", "*)"}], "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"rels", "[", 
         RowBox[{"i_", ",", "t_"}], "]"}], ":=", 
        FractionBox[
         RowBox[{
          SubscriptBox["propN", "i"], " ", 
          SubsuperscriptBox["\[Beta]", "i", "t"]}], 
         RowBox[{
          SubscriptBox["propN", "1"], " ", 
          SubsuperscriptBox["\[Beta]", "1", "t"]}]]}], ";", 
       RowBox[{"(*", 
        RowBox[{
         RowBox[{
         "This", " ", "is", " ", "equivalent", " ", "to", " ", "evaluating", 
          " ", 
          FractionBox[
           RowBox[{"s", "[", 
            RowBox[{"i", ",", "numberGenerations"}], "]"}], 
           RowBox[{"s", "[", 
            RowBox[{"1", ",", "numberGenerations"}], "]"}]]}], ",", " ", 
         RowBox[{"and", " ", "this", " ", "just", " ", "saves", " ", 
          RowBox[{"time", "."}]}]}], "*)"}], "\[IndentingNewLine]", 
       "\[IndentingNewLine]", 
       RowBox[{"(*", 
        RowBox[{"Calculate", " ", 
         SubscriptBox["propN", "i"], " ", "relative", " ", "to", " ", 
         RowBox[{
          SubscriptBox["propN", "1"], " ", ".", " ", "This"}], " ", "will", 
         " ", "enable", " ", "us", " ", "to", " ", "calculate", " ", "the", 
         " ", "distribution", " ", "of", " ", "agents", " ", "at", " ", 
         "time", " ", "zero", " ", 
         RowBox[{"(", 
          RowBox[{
           RowBox[{"i", ".", "e", ".", " ", "the"}], " ", "year", " ", 
           "1300"}], ")"}]}], "*)"}], "\[IndentingNewLine]", 
       RowBox[{"propans", "=", 
        RowBox[{
         RowBox[{"(", 
          RowBox[{
           RowBox[{"Solve", "[", 
            RowBox[{
             RowBox[{"Thread", "[", 
              RowBox[{
               RowBox[{"Rest", "[", 
                RowBox[{"Table", "[", 
                 RowBox[{
                  RowBox[{"rels", "[", 
                   RowBox[{"i", ",", "numberGenerations"}], "]"}], ",", 
                  RowBox[{"{", 
                   RowBox[{"i", ",", "1", ",", "nTypes"}], "}"}]}], "]"}], 
                "]"}], "\[Equal]", 
               RowBox[{"Rest", "[", 
                RowBox[{"reldistributionToday", "[", 
                 RowBox[{"[", 
                  RowBox[{"All", ",", "2"}], "]"}], "]"}], "]"}]}], "]"}], 
             ",", 
             RowBox[{"Table", "[", 
              RowBox[{
               SubscriptBox["propN", "i"], ",", 
               RowBox[{"{", 
                RowBox[{"i", ",", "2", ",", "nTypes"}], "}"}]}], "]"}]}], 
            "]"}], "/.", 
           RowBox[{"Table", "[", 
            RowBox[{
             RowBox[{
              SubscriptBox["\[Beta]", "i"], "->", 
              RowBox[{
               RowBox[{"distributionToday", "[", 
                RowBox[{"[", 
                 RowBox[{"All", ",", "1"}], "]"}], "]"}], "[", 
               RowBox[{"[", "i", "]"}], "]"}]}], ",", 
             RowBox[{"{", 
              RowBox[{"i", ",", "1", ",", "nTypes"}], "}"}]}], "]"}]}], ")"}],
          "[", 
         RowBox[{"[", "1", "]"}], "]"}]}], ";", " ", "\[IndentingNewLine]", 
       RowBox[{"initialDistribution", "=", 
        RowBox[{"Table", "[", 
         RowBox[{
          RowBox[{
           RowBox[{"rels", "[", 
            RowBox[{"i", ",", "0"}], "]"}], "/.", "propans"}], ",", 
          RowBox[{"{", 
           RowBox[{"i", ",", "1", ",", "nTypes"}], "}"}]}], "]"}]}], ";", 
       "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{"Return", "[", 
        RowBox[{"Transpose", "[", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"distributionToday", "[", 
            RowBox[{"[", 
             RowBox[{"All", ",", "1"}], "]"}], "]"}], ",", 
           "initialDistribution"}], "}"}], "]"}], "]"}], ";"}]}], 
     "\[IndentingNewLine]", "\[IndentingNewLine]", "]"}]}]}], ";"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10002.},
 CellChangeTimes->{{3.773059203269739*^9, 3.7730592321362514`*^9}, {
   3.773059270645217*^9, 3.773059408530589*^9}, {3.7730594529909477`*^9, 
   3.773059461150528*^9}, {3.7730595887871466`*^9, 3.773059604298814*^9}, {
   3.7730598815452766`*^9, 3.7730599058649607`*^9}, {3.773059972836586*^9, 
   3.773060039982541*^9}, {3.773060112893183*^9, 3.7730601144986362`*^9}, 
   3.7730604066945143`*^9, {3.773060487195585*^9, 3.773060495031698*^9}, 
   3.7730633167129974`*^9, 3.8518460626313715`*^9, {3.8527224615184765`*^9, 
   3.852722534680199*^9}, 3.852723813465619*^9, {3.8527245400750127`*^9, 
   3.8527245544772696`*^9}, {3.8987668599363956`*^9, 3.89876686567155*^9}},
 CellLabel->"In[26]:=",ExpressionUUID->"de110204-d22e-4104-951b-996735b9f8e2"]
}, Closed]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{"findInitialDistributionHelper", " ", "-", " ", 
   RowBox[{
   "Finds", " ", "the", " ", "initial", " ", "distribution", " ", "given", 
    " ", "input", " ", "Data"}], " ", "-", " ", 
   RowBox[{"takes", " ", "into", " ", "account", " ", "\[Omega]"}]}], 
  "*)"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10003.},
 CellChangeTimes->{{3.898829692089343*^9, 3.898829756442272*^9}, 
   3.899183623278308*^9, 3.902726251930418*^9},
 CellLabel->"In[27]:=",ExpressionUUID->"3ecef7cf-5e31-4253-b90c-bb19558da7d5"],

Cell[BoxData[
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"findInitialDistributionHelper", "[", "inputData_", "]"}], ":=", 
    RowBox[{
     RowBox[{"findInitialDistributionHelper", "[", "inputData", "]"}], "=", 
     RowBox[{"Module", "[", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{
        "allParms", ",", "distt2000", ",", "averageBeta2000", ",", 
         "initialDistributionTilde", ",", "pp", ",", "temp", ",", 
         "initialDistribution"}], "}"}], ",", 
       RowBox[{
        RowBox[{"allParms", "=", 
         RowBox[{"calibration", "[", "inputData", "]"}]}], ";", 
        "\[IndentingNewLine]", 
        RowBox[{"distt2000", "=", 
         RowBox[{"genBetaDistribution2", "[", 
          RowBox[{"0", ",", 
           RowBox[{"betamax", "/.", "allParms"}], ",", 
           RowBox[{"\[Gamma]", "/.", "allParms"}], ",", 
           RowBox[{"delta", "/.", "allParms"}], ",", 
           RowBox[{"nTypes", "/.", "allParms"}], ",", 
           RowBox[{"precision", "/.", "allParms"}]}], "]"}]}], ";", 
        "\[IndentingNewLine]", 
        RowBox[{"averageBeta2000", "=", 
         RowBox[{"Mean", "[", 
          RowBox[{"WeightedData", "[", 
           RowBox[{
            RowBox[{"distt2000", "[", 
             RowBox[{"[", 
              RowBox[{"All", ",", "1"}], "]"}], "]"}], ",", 
            RowBox[{"distt2000", "[", 
             RowBox[{"[", 
              RowBox[{"All", ",", "2"}], "]"}], "]"}]}], "]"}], "]"}]}], ";", 
        "\[IndentingNewLine]", 
        RowBox[{"initialDistributionTilde", "=", 
         RowBox[{"findInitialDistribution", "[", 
          RowBox[{"distt2000", ",", 
           RowBox[{"currentyear", "/.", "allParms"}], ",", 
           RowBox[{"inityear", "/.", "allParms"}]}], "]"}]}], ";", 
        "\[IndentingNewLine]", 
        RowBox[{"pp", "=", 
         RowBox[{"Join", "[", 
          RowBox[{
           RowBox[{"Table", "[", 
            RowBox[{
             RowBox[{
              SubscriptBox["\[Beta]", "i"], "\[Rule]", 
              RowBox[{"initialDistributionTilde", "[", 
               RowBox[{"[", 
                RowBox[{"i", ",", "1"}], "]"}], "]"}]}], ",", 
             RowBox[{"{", 
              RowBox[{"i", ",", "1", ",", 
               RowBox[{"nTypes", "/.", "allParms"}]}], "}"}]}], "]"}], ",", 
           RowBox[{"{", 
            RowBox[{"\[Alpha]", "\[Rule]", 
             RowBox[{"(", 
              RowBox[{"\[Alpha]", "/.", "allParms"}], ")"}]}], "}"}], ",", 
           RowBox[{"{", 
            RowBox[{
             SubscriptBox["Pie", "t"], "\[Rule]", 
             RowBox[{
              RowBox[{"(", 
               RowBox[{"Pie", "/.", "allParms"}], ")"}], "[", 
              RowBox[{"[", "1", "]"}], "]"}]}], "}"}], ",", 
           RowBox[{"{", 
            RowBox[{"Piess", "\[Rule]", 
             RowBox[{"(", 
              RowBox[{"Piess", "/.", "allParms"}], ")"}]}], "}"}], ",", 
           RowBox[{"{", 
            RowBox[{"\[Omega]", "\[Rule]", 
             RowBox[{"(", 
              RowBox[{"\[Omega]", "/.", "allParms"}], ")"}]}], "}"}]}], 
          "]"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
        RowBox[{"temp", "=", 
         RowBox[{
          RowBox[{
           RowBox[{"initialDistributionTilde", "[", 
            RowBox[{"[", 
             RowBox[{"All", ",", "2"}], "]"}], "]"}], 
           RowBox[{"(", 
            FractionBox[
             FractionBox[
              RowBox[{"1", "-", "\[Alpha]", "-", 
               RowBox[{
                RowBox[{"(", 
                 RowBox[{"\[Omega]", "+", 
                  RowBox[{
                   RowBox[{"(", 
                    RowBox[{"1", "-", "\[Omega]"}], ")"}], " ", 
                   SubscriptBox["Pie", "t"]}]}], ")"}], " ", 
                RowBox[{"initialDistributionTilde", "[", 
                 RowBox[{"[", 
                  RowBox[{"All", ",", "1"}], "]"}], "]"}]}]}], 
              RowBox[{"1", "-", "\[Alpha]", "-", 
               RowBox[{
                RowBox[{"(", 
                 RowBox[{"\[Omega]", "+", 
                  RowBox[{
                   RowBox[{"(", 
                    RowBox[{"1", "-", "\[Omega]"}], ")"}], " ", "Piess"}]}], 
                 ")"}], " ", 
                RowBox[{"initialDistributionTilde", "[", 
                 RowBox[{"[", 
                  RowBox[{"All", ",", "1"}], "]"}], "]"}]}]}]], 
             FractionBox[
              RowBox[{"1", "-", "\[Alpha]", "-", 
               RowBox[{
                RowBox[{"(", 
                 RowBox[{"\[Omega]", "+", 
                  RowBox[{
                   RowBox[{"(", 
                    RowBox[{"1", "-", "\[Omega]"}], ")"}], " ", 
                   SubscriptBox["Pie", "t"]}]}], ")"}], " ", 
                SubscriptBox["\[Beta]", "1"]}]}], 
              RowBox[{"1", "-", "\[Alpha]", "-", 
               RowBox[{
                RowBox[{"(", 
                 RowBox[{"\[Omega]", "+", 
                  RowBox[{
                   RowBox[{"(", 
                    RowBox[{"1", "-", "\[Omega]"}], ")"}], " ", "Piess"}]}], 
                 ")"}], " ", 
                SubscriptBox["\[Beta]", "1"]}]}]]], ")"}]}], "/.", "pp"}]}], 
        ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
        "\[IndentingNewLine]", 
        RowBox[{"initialDistribution", "=", "initialDistributionTilde"}], ";",
         "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"initialDistribution", "[", 
          RowBox[{"[", 
           RowBox[{"All", ",", "2"}], "]"}], "]"}], "=", "temp"}], ";", 
        "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
        RowBox[{"Return", "[", 
         RowBox[{"{", 
          RowBox[{
          "initialDistribution", ",", "allParms", ",", "averageBeta2000"}], 
          "}"}], "]"}], ";"}]}], "\[IndentingNewLine]", "]"}]}]}], ";"}], 
  "\n"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10003.},
 CellChangeTimes->{{3.898829565444118*^9, 3.8988295965861588`*^9}, {
   3.89882967870833*^9, 3.898829679259362*^9}, 3.8988297564425507`*^9, {
   3.898829992820813*^9, 3.898829995602569*^9}, {3.898831377187161*^9, 
   3.898831389937358*^9}, {3.898832614831257*^9, 3.898832615309999*^9}, {
   3.89883299476865*^9, 3.898832995344182*^9}, {3.898834637691581*^9, 
   3.898834644642989*^9}, {3.8988370683321943`*^9, 3.898837070705077*^9}, 
   3.8991836232788897`*^9, 3.902726251930686*^9},
 CellLabel->"In[28]:=",ExpressionUUID->"1f23d4ed-3961-499b-8060-9a58d7b39ad6"]
}, Closed]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{"levelsFromGrowthData", "[", 
   RowBox[{
   "inityear_", ",", "currentyear_", ",", "futureyears_", ",", "grcuttoff_"}],
    "]"}], "*)"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.},
 CellChangeTimes->{{3.8526165917474003`*^9, 3.852616592703644*^9}, 
   3.8526168100254116`*^9, {3.8526172914914427`*^9, 3.8526172914914427`*^9}},
 CellLabel->"In[29]:=",ExpressionUUID->"41f72e75-c163-48ee-89be-74d9ec6c244a"],

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{
   RowBox[{
   "Takes", " ", "growth", " ", "rates", " ", "and", " ", "the", " ", 
    "cutoff", " ", "time", " ", "periods", " ", "they", " ", "pertain", " ", 
    "to", " ", "and", " ", "generates", " ", "the", " ", "corresponding", " ",
     "level", " ", "starting", " ", "from", " ", "1.", " ", 
    RowBox[{"e", ".", "g", ".", " ", "Suppose"}], " ", "productivity", " ", 
    "growth", " ", "rates", " ", "are", "  ", "1.005688502", " ", "before", 
    " ", "1800"}], ",", " ", 
   RowBox[{
   "1.102042773", " ", "between", " ", "then", " ", "and", " ", "1875", " ", 
    "and", " ", "1.261746102", " ", "after", " ", "that"}], ",", " ", 
   RowBox[{
    RowBox[{
    "it", " ", "will", " ", "generate", " ", "the", " ", "TFP", " ", 
     "function", " ", "starting", " ", "from", " ", "inityear"}], "-", 
    RowBox[{
    "25", " ", "to", " ", "futureyears", " ", "years", " ", "after", " ", 
     "currentyear"}]}]}], " ", "*)"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.},
 CellChangeTimes->{{3.8526165941512346`*^9, 3.852616728381709*^9}, 
   3.8526168100254116`*^9, {3.8526172915071077`*^9, 3.8526172915071077`*^9}},
 CellLabel->"In[30]:=",ExpressionUUID->"001d8964-bdf3-45d3-95e7-a7f4d1b66ef8"],

Cell[BoxData[
 RowBox[{
  RowBox[{
   RowBox[{"levelsFromGrowthData", "[", 
    RowBox[{
    "inityearparm_", ",", "currentyearparm_", ",", "futureyearsparm_", ",", 
     "grcuttoffparm_"}], "]"}], ":=", "\[IndentingNewLine]", 
   RowBox[{"Module", "[", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{
       RowBox[{"inityear", "=", "inityearparm"}], ",", 
       RowBox[{"currentyear", "=", "currentyearparm"}], ",", 
       RowBox[{"futureyears", "=", "futureyearsparm"}], ",", 
       RowBox[{"grcuttoff", "=", "grcuttoffparm"}], ",", "func", ",", "data", 
       ",", "gData", ",", "years"}], "}"}], ",", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"years", "=", 
       RowBox[{
        FractionBox[
         RowBox[{"currentyear", "-", "inityear"}], "25"], "+", 
        FractionBox["futureyears", "25"]}]}], ";", "\[IndentingNewLine]", 
      RowBox[{"gData", "=", 
       RowBox[{"Table", "[", 
        RowBox[{
         RowBox[{"If", "[", 
          RowBox[{
           RowBox[{
            RowBox[{
             RowBox[{"t", "*", "25"}], "+", 
             RowBox[{"(", 
              RowBox[{"inityear", "-", "25"}], ")"}]}], "<", 
            RowBox[{"grcuttoff", "[", 
             RowBox[{"[", 
              RowBox[{"1", ",", "1"}], "]"}], "]"}]}], ",", 
           RowBox[{"grcuttoff", "[", 
            RowBox[{"[", 
             RowBox[{"1", ",", "2"}], "]"}], "]"}], ",", 
           RowBox[{"If", "[", 
            RowBox[{
             RowBox[{
              RowBox[{
               RowBox[{"t", "*", "25"}], "+", 
               RowBox[{"(", 
                RowBox[{"inityear", "-", "25"}], ")"}]}], "\[LessEqual]", 
              RowBox[{"grcuttoff", "[", 
               RowBox[{"[", 
                RowBox[{"2", ",", "1"}], "]"}], "]"}]}], ",", 
             RowBox[{"grcuttoff", "[", 
              RowBox[{"[", 
               RowBox[{"2", ",", "2"}], "]"}], "]"}], ",", 
             RowBox[{"grcuttoff", "[", 
              RowBox[{"[", 
               RowBox[{"3", ",", "2"}], "]"}], "]"}]}], "]"}]}], "]"}], ",", 
         RowBox[{"{", 
          RowBox[{"t", ",", "0", ",", "years"}], "}"}]}], "]"}]}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"func", "[", "t_", "]"}], ":=", 
       RowBox[{"If", "[", 
        RowBox[{
         RowBox[{"t", "\[Equal]", "1"}], ",", "1", ",", 
         RowBox[{
          RowBox[{"func", "[", 
           RowBox[{"t", "-", "1"}], "]"}], "*", 
          RowBox[{"gData", "[", 
           RowBox[{"[", "t", "]"}], "]"}]}]}], "]"}]}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{"data", "=", 
       RowBox[{"Table", "[", 
        RowBox[{
         RowBox[{"func", "[", "t", "]"}], ",", 
         RowBox[{"{", 
          RowBox[{"t", ",", "1", ",", "years"}], "}"}]}], "]"}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"Return", "[", "data", "]"}], ";"}]}], "\[IndentingNewLine]", 
    "]"}]}], "\[IndentingNewLine]", "\[IndentingNewLine]", 
  "\[IndentingNewLine]"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.},
 CellChangeTimes->{
  3.8526139005805607`*^9, {3.8526143681958337`*^9, 3.852614378374804*^9}, {
   3.8526146882096*^9, 3.852614690678112*^9}, {3.8526148336788416`*^9, 
   3.852614846698921*^9}, {3.8526151537367554`*^9, 3.852615154252261*^9}, {
   3.852615306253538*^9, 3.852615375511843*^9}, {3.852615412783349*^9, 
   3.8526154245047517`*^9}, {3.8526155263069143`*^9, 3.852615604017879*^9}, {
   3.8526157076768427`*^9, 3.852615827325252*^9}, {3.8526160514268627`*^9, 
   3.8526160799314594`*^9}, {3.8526163214517317`*^9, 
   3.8526163527211065`*^9}, {3.852616389760595*^9, 3.852616403827162*^9}, {
   3.852616465118318*^9, 3.8526164824852877`*^9}, 3.8526165907933626`*^9, {
   3.8526167494867587`*^9, 3.852616750006382*^9}, 3.8526168100254116`*^9, {
   3.8526172915071077`*^9, 3.852617291522686*^9}, {3.8526191301557817`*^9, 
   3.852619155711249*^9}},
 CellLabel->"In[31]:=",ExpressionUUID->"6920635c-271c-4673-a1fa-95380b89c0f9"]
}, Closed]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{
  "`InterpolateLists`", " ", "is", " ", "a", " ", "function", " ", "that", 
   " ", "interpolates", " ", "between", " ", "two", " ", "given", " ", 
   "lists", " ", "over", " ", "a", " ", "specified", " ", "number", " ", "of",
    " ", "steps", " ", "using", " ", "a", " ", "chosen", " ", "interpolation",
    " ", 
   RowBox[{"method", ".", "It"}], " ", "returns", " ", "a", " ", "list", " ", 
   "of", " ", "interpolated", " ", 
   RowBox[{"lists", ".", " ", "See"}], " ", "inside", " ", "for", " ", 
   "details"}], "*)"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.},
 CellChangeTimes->{{3.894010907052895*^9, 3.894010926190184*^9}, 
   3.894601281169641*^9},
 CellLabel->"In[32]:=",ExpressionUUID->"8285b187-fce7-40cf-93e1-1cbaa42b7161"],

Cell[BoxData[
 RowBox[{
  RowBox[{
   RowBox[{"InterpolateLists", "[", 
    RowBox[{
    "initialList_", ",", "targetList_", ",", "numberOfSteps_", ",", 
     "method_"}], "]"}], ":=", 
   RowBox[{"Module", "[", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"controlPoints", ",", "bSpline"}], "}"}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{"Switch", "[", 
      RowBox[{"method", ",", "\"\<linear\>\"", ",", 
       RowBox[{"Table", "[", 
        RowBox[{
         RowBox[{"initialList", "+", 
          RowBox[{
           RowBox[{"step", "/", "numberOfSteps"}], "*", 
           RowBox[{"(", 
            RowBox[{"targetList", "-", "initialList"}], ")"}]}]}], ",", 
         RowBox[{"{", 
          RowBox[{"step", ",", "0", ",", "numberOfSteps"}], "}"}]}], "]"}], 
       ",", "\"\<exponential\>\"", ",", 
       RowBox[{"Table", "[", 
        RowBox[{
         RowBox[{
          RowBox[{"initialList", "*", 
           RowBox[{
            RowBox[{"(", 
             RowBox[{"1", "-", 
              RowBox[{"step", "/", "numberOfSteps"}]}], ")"}], "^", "2"}]}], 
          "+", 
          RowBox[{"targetList", "*", 
           RowBox[{
            RowBox[{"(", 
             RowBox[{"step", "/", "numberOfSteps"}], ")"}], "^", "2"}]}]}], 
         ",", 
         RowBox[{"{", 
          RowBox[{"step", ",", "0", ",", "numberOfSteps"}], "}"}]}], "]"}], 
       ",", "\"\<sigmoid\>\"", ",", 
       RowBox[{
        RowBox[{
         RowBox[{"sigmoid", "[", "x_", "]"}], ":=", 
         RowBox[{"1", "/", 
          RowBox[{"(", 
           RowBox[{"1", "+", 
            RowBox[{"Exp", "[", 
             RowBox[{"-", "x"}], "]"}]}], ")"}]}]}], ";", 
        "\[IndentingNewLine]", 
        RowBox[{"Table", "[", 
         RowBox[{
          RowBox[{
           RowBox[{"initialList", "*", 
            RowBox[{"sigmoid", "[", 
             RowBox[{
              RowBox[{"-", "5"}], "+", 
              RowBox[{"10", "*", 
               RowBox[{"(", 
                RowBox[{"step", "/", "numberOfSteps"}], ")"}]}]}], "]"}]}], 
           "+", 
           RowBox[{"targetList", "*", 
            RowBox[{"sigmoid", "[", 
             RowBox[{"5", "-", 
              RowBox[{"10", "*", 
               RowBox[{"(", 
                RowBox[{"step", "/", "numberOfSteps"}], ")"}]}]}], "]"}]}]}], 
          ",", 
          RowBox[{"{", 
           RowBox[{"step", ",", "0", ",", "numberOfSteps"}], "}"}]}], "]"}]}],
        ",", "\"\<cosine\>\"", ",", 
       RowBox[{"Table", "[", 
        RowBox[{
         RowBox[{
          RowBox[{
           RowBox[{"(", 
            RowBox[{"initialList", "+", "targetList"}], ")"}], "/", "2"}], 
          "+", 
          RowBox[{
           RowBox[{
            RowBox[{"(", 
             RowBox[{"initialList", "-", "targetList"}], ")"}], "/", "2"}], 
           "*", 
           RowBox[{"Cos", "[", 
            RowBox[{
             RowBox[{"step", "/", "numberOfSteps"}], "*", "Pi"}], "]"}]}]}], 
         ",", 
         RowBox[{"{", 
          RowBox[{"step", ",", "0", ",", "numberOfSteps"}], "}"}]}], "]"}], 
       ",", "\"\<b-spline\>\"", ",", 
       RowBox[{
        RowBox[{"controlPoints", "=", 
         RowBox[{"{", 
          RowBox[{"initialList", ",", "targetList"}], "}"}]}], ";", "\n", 
        RowBox[{"bSpline", "=", 
         RowBox[{"BSplineFunction", "[", 
          RowBox[{"controlPoints", ",", 
           RowBox[{"SplineDegree", "->", "1"}]}], "]"}]}], ";", "\n", 
        RowBox[{"Table", "[", 
         RowBox[{
          RowBox[{"bSpline", "[", 
           RowBox[{"step", "/", "numberOfSteps"}], "]"}], ",", 
          RowBox[{"{", 
           RowBox[{"step", ",", "0", ",", "numberOfSteps"}], "}"}]}], 
         "]"}]}]}], "\[IndentingNewLine]", "]"}]}], "\[IndentingNewLine]", 
    "]"}]}], ";"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.},
 CellChangeTimes->{{3.894009853780623*^9, 3.8940098772229223`*^9}, {
   3.894010203400783*^9, 3.8940102841719646`*^9}, {3.894010551482448*^9, 
   3.894010576199025*^9}, {3.894010716733554*^9, 3.894010726699997*^9}, 
   3.894010863071501*^9, 3.89401092619071*^9, 3.894601281169847*^9},
 CellLabel->"In[33]:=",ExpressionUUID->"843acaaa-a990-48ee-99d5-48cd91aa6919"],

Cell["\<\
(*This function interpolates between two lists over a specified number of \
steps.

Inputs:
1) initialList:The starting list of values.
2) targetList:The ending list of values.Both lists must be the same length.
3) numberOfSteps:The number of steps to interpolate over.
4) method:A string specifying the type of interpolation to use.Options are \
\"linear\",\"exponential\",\"sigmoid\", \"cosine\[CloseCurlyDoubleQuote] or \
\[OpenCurlyDoubleQuote]b-spline\[CloseCurlyDoubleQuote].

Exponential Interpolation:This type of interpolation can be particularly \
useful when you want the rate of change to increase or decrease exponentially \
rather than linearly over time.
Sigmoid Interpolation:This interpolation gives a smooth,S-shaped transition \
from the initial to the target state.
Cosine Interpolation:This provides a smooth transition that can be easier on \
systems that don\[CloseCurlyQuote]t handle rapid change well.
B-spline Interpolation: B-splines are basis functions for spline \
interpolation. These are piecewise-defined polynomials of degree n, defined \
over a sequence of knots. B-spline interpolation can be used when we want \
smoothness and stability. In this method,the initialList and targetList are \
treated as control points for the B-spline,and the interpolation is performed \
along the path defined by these points.B-splines provide a smooth \
interpolation that avoids the oscillations that can occur with high-degree \
polynomial interpolation,allowing for local control of the shape of the curve.

Usage example:initialList={1.,0.983425,...,8.38485};
targetList=ConstantArray[1,Length[initialList]];
numberOfSteps=100;
interpolationList=InterpolateLists[initialList,targetList,numberOfSteps,\"\
sigmoid\"];
This will return a list of'numberOfSteps'+1 lists,where each element of the \
list is a step in the interpolation from the initialList to the \
targetList.The interpolation method used is specified by the'method' \
argument.*)\
\>", "CodeText",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.},
 CellChangeTimes->{{3.894010298612689*^9, 3.894010346739744*^9}, {
   3.894010674030353*^9, 3.89401068589053*^9}, {3.894010830599743*^9, 
   3.8940108484082613`*^9}, 3.89401092619203*^9, 
   3.8946012811708717`*^9},ExpressionUUID->"62ef0130-7b9a-4023-b534-\
4aa698d0a8c9"]
}, Closed]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"(*", 
  "\"\<`findMinPoint \[IndentingNewLine]is a module that finds the point \
(a,b,c) that minimizes the Euclidean distance between the output of a given \
test[x,y,z] function and a target value. It uses interpolation and a grid \
search algorithm to perform the optimization iteratively,updating the guess \
in the sequence:z->y->x.\>\"", "*)"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.},
 CellChangeTimes->{{3.896173436575965*^9, 3.8961734685809107`*^9}, {
  3.896173848634305*^9, 3.8961738539800177`*^9}},
 CellLabel->"In[34]:=",ExpressionUUID->"b970fc46-3af7-4ca6-b306-a38620a56cba"],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"findMinPoint", "[", 
     RowBox[{
     "initialPoint_", ",", "gridDensity_", ",", "delta_", ",", "target_", ",",
       "testFunc_"}], "]"}], ":=", 
    RowBox[{"Module", "[", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{
       "nx", ",", "ny", ",", "nz", ",", "dx", ",", "dy", ",", "dz", ",", 
        "data", ",", "gc", ",", "gb", ",", "ga", ",", "a", ",", "b", ",", "c",
         ",", "x", ",", "y", ",", "z", ",", "timing"}], "}"}], ",", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"timing", "=", 
        RowBox[{"AbsoluteTiming", "[", "\[IndentingNewLine]", 
         RowBox[{
          RowBox[{
           RowBox[{"{", 
            RowBox[{"a", ",", "b", ",", "c"}], "}"}], "=", "initialPoint"}], 
          ";", "\[IndentingNewLine]", 
          RowBox[{
           RowBox[{"{", 
            RowBox[{"nx", ",", "ny", ",", "nz"}], "}"}], "=", "gridDensity"}],
           ";", "\[IndentingNewLine]", 
          RowBox[{
           RowBox[{"{", 
            RowBox[{"dx", ",", "dy", ",", "dz"}], "}"}], "=", "delta"}], ";", 
          "\[IndentingNewLine]", "\[IndentingNewLine]", 
          RowBox[{"(*", 
           RowBox[{"Interpolate", " ", "around", " ", 
            RowBox[{"(", 
             RowBox[{"a", ",", "b", ",", "c"}], ")"}], " ", "in", " ", "z"}], 
           "*)"}], "\[IndentingNewLine]", "\[IndentingNewLine]", 
          RowBox[{"data", "=", 
           RowBox[{"ParallelTable", "[", 
            RowBox[{
             RowBox[{"{", 
              RowBox[{"z", ",", 
               RowBox[{"Norm", "[", 
                RowBox[{
                 RowBox[{"testFunc", "[", 
                  RowBox[{"a", ",", "b", ",", "z"}], "]"}], "-", "target"}], 
                "]"}]}], "}"}], ",", 
             RowBox[{"{", 
              RowBox[{"z", ",", 
               RowBox[{"c", "-", "dz"}], ",", 
               RowBox[{"c", "+", "dz"}], ",", 
               RowBox[{
                RowBox[{"(", 
                 RowBox[{"2", "*", "dz"}], ")"}], "/", 
                RowBox[{"(", 
                 RowBox[{"nz", "-", "1"}], ")"}]}]}], "}"}]}], "]"}]}], ";", 
          "\[IndentingNewLine]", 
          RowBox[{"gc", "=", 
           RowBox[{"Interpolation", "[", "data", "]"}]}], ";", 
          "\[IndentingNewLine]", 
          RowBox[{"c", "=", 
           RowBox[{"z", "/.", " ", 
            RowBox[{"Last", "[", 
             RowBox[{"NMinimize", "[", 
              RowBox[{
               RowBox[{"{", 
                RowBox[{
                 RowBox[{"gc", "[", "z", "]"}], ",", 
                 RowBox[{
                  RowBox[{"c", "-", "dz"}], "<=", "z", "<=", 
                  RowBox[{"c", "+", "dz"}]}]}], "}"}], ",", "z"}], "]"}], 
             "]"}]}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
          RowBox[{"(*", 
           RowBox[{"Clear", " ", "interpolation", " ", "function"}], "*)"}], 
          "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
          RowBox[{"(*", 
           RowBox[{"Interpolate", " ", "around", " ", 
            RowBox[{"(", 
             RowBox[{"a", ",", "b", ",", "c"}], ")"}], " ", "in", " ", "y"}], 
           "*)"}], 
          RowBox[{"data", "=", 
           RowBox[{"ParallelTable", "[", 
            RowBox[{
             RowBox[{"{", 
              RowBox[{"y", ",", 
               RowBox[{"Norm", "[", 
                RowBox[{
                 RowBox[{"testFunc", "[", 
                  RowBox[{"a", ",", "y", ",", "c"}], "]"}], "-", "target"}], 
                "]"}]}], "}"}], ",", 
             RowBox[{"{", 
              RowBox[{"y", ",", 
               RowBox[{"b", "-", "dy"}], ",", 
               RowBox[{"b", "+", "dy"}], ",", 
               RowBox[{
                RowBox[{"(", 
                 RowBox[{"2", "*", "dy"}], ")"}], "/", 
                RowBox[{"(", 
                 RowBox[{"ny", "-", "1"}], ")"}]}]}], "}"}]}], "]"}]}], ";", 
          "\[IndentingNewLine]", 
          RowBox[{"gb", "=", 
           RowBox[{"Interpolation", "[", "data", "]"}]}], ";", 
          "\[IndentingNewLine]", 
          RowBox[{"b", "=", 
           RowBox[{"y", "/.", " ", 
            RowBox[{"Last", "[", 
             RowBox[{"NMinimize", "[", 
              RowBox[{
               RowBox[{"{", 
                RowBox[{
                 RowBox[{"gb", "[", "y", "]"}], ",", 
                 RowBox[{
                  RowBox[{"b", "-", "dy"}], "<=", "y", "<=", 
                  RowBox[{"b", "+", "dy"}]}]}], "}"}], ",", "y"}], "]"}], 
             "]"}]}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
          RowBox[{"(*", 
           RowBox[{"Clear", " ", "interpolation", " ", "function"}], "*)"}], 
          "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
          RowBox[{"(*", 
           RowBox[{"Interpolate", " ", "around", " ", 
            RowBox[{"(", 
             RowBox[{"a", ",", "b", ",", "c"}], ")"}], " ", "in", " ", "x"}], 
           "*)"}], 
          RowBox[{"data", "=", 
           RowBox[{"ParallelTable", "[", 
            RowBox[{
             RowBox[{"{", 
              RowBox[{"x", ",", 
               RowBox[{"Norm", "[", 
                RowBox[{
                 RowBox[{"testFunc", "[", 
                  RowBox[{"x", ",", "b", ",", "c"}], "]"}], "-", "target"}], 
                "]"}]}], "}"}], ",", 
             RowBox[{"{", 
              RowBox[{"x", ",", 
               RowBox[{"a", "-", "dx"}], ",", 
               RowBox[{"a", "+", "dx"}], ",", 
               RowBox[{
                RowBox[{"(", 
                 RowBox[{"2", "*", "dx"}], ")"}], "/", 
                RowBox[{"(", 
                 RowBox[{"nx", "-", "1"}], ")"}]}]}], "}"}]}], "]"}]}], ";", 
          "\[IndentingNewLine]", 
          RowBox[{"ga", "=", 
           RowBox[{"Interpolation", "[", "data", "]"}]}], ";", 
          "\[IndentingNewLine]", 
          RowBox[{"a", "=", 
           RowBox[{"x", "/.", " ", 
            RowBox[{"Last", "[", 
             RowBox[{"NMinimize", "[", 
              RowBox[{
               RowBox[{"{", 
                RowBox[{
                 RowBox[{"ga", "[", "x", "]"}], ",", 
                 RowBox[{
                  RowBox[{"a", "-", "dx"}], "<=", "x", "<=", 
                  RowBox[{"a", "+", "dx"}]}]}], "}"}], ",", "x"}], "]"}], 
             "]"}]}]}], ";"}], "\[IndentingNewLine]", "\[IndentingNewLine]", 
         RowBox[{"(*", 
          RowBox[{"Clear", " ", "interpolation", " ", "function"}], "*)"}], 
         "\[IndentingNewLine]", "]"}]}], ";", "\[IndentingNewLine]", 
       "\[IndentingNewLine]", 
       RowBox[{"(*", 
        RowBox[{"Print", " ", "the", " ", "result"}], "*)"}], 
       RowBox[{"PrintTemporary", "[", 
        RowBox[{
        "\"\<Final a = \>\"", ",", "a", ",", "\"\<, b = \>\"", ",", "b", ",", 
         "\"\<, c = \>\"", ",", "c", ",", "\"\<, Norm = \>\"", ",", 
         RowBox[{"Norm", "[", 
          RowBox[{
           RowBox[{"testFunc", "[", 
            RowBox[{"a", ",", "b", ",", "c"}], "]"}], "-", "target"}], "]"}], 
         ",", "\"\<, Mem in Use = \>\"", ",", 
         RowBox[{"MemoryInUse", "[", "]"}], ",", "\"\<, Time = \>\"", ",", 
         RowBox[{"timing", "[", 
          RowBox[{"[", "1", "]"}], "]"}]}], "]"}], ";", "\[IndentingNewLine]",
        "\[IndentingNewLine]", 
       RowBox[{"(*", 
        RowBox[{
        "Return", " ", "the", " ", "final", " ", "point", " ", "and", " ", 
         "the", " ", "norm"}], "*)"}], "\[IndentingNewLine]", 
       "\[IndentingNewLine]", 
       RowBox[{"Remove", "[", 
        RowBox[{
        "gc", ",", "gb", ",", "ga", ",", "nx", ",", "ny", ",", "nz", ",", 
         "dx", ",", "dy", ",", "dz", ",", "data", ",", "x", ",", "y", ",", 
         "z"}], "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{"Return", "[", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"{", 
           RowBox[{"a", ",", "b", ",", "c"}], "}"}], ",", 
          RowBox[{"Norm", "[", 
           RowBox[{
            RowBox[{"testFunc", "[", 
             RowBox[{"a", ",", "b", ",", "c"}], "]"}], "-", "target"}], 
           "]"}]}], "}"}], "]"}], ";"}]}], "\[IndentingNewLine]", "]"}]}], 
   ";"}], "\[IndentingNewLine]"}], "\n", 
 RowBox[{
  RowBox[{
  "(*", "\"\<Inputs:-initialPoint:A list of three initial guesses for the \
values of {a,b,c}.-gridDensity:A list of three integers defining the number \
of points to be considered on the grid for each dimension.-delta:A list of \
three positive values defining the search interval size around the current \
guess for each dimension.-target:A numeric target value that we aim to \
approach with the output of the test function.-testFunc:The test function \
which is being minimized.It should accept three numeric arguments.Output:-A \
list containing the optimized point {a,b,c} and the final Euclidean distance \
between the output of the test function and the target value at the optimized \
point.\>\"", "*)"}]}]}], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.},
 CellChangeTimes->{{3.8961708557178993`*^9, 3.896170855722467*^9}, {
   3.896170890115744*^9, 3.896170892391782*^9}, {3.8961713999259253`*^9, 
   3.896171433178339*^9}, {3.8961718006426*^9, 3.896171813531196*^9}, 
   3.8961718711487017`*^9, {3.896173412632606*^9, 3.89617343428267*^9}, {
   3.896173468581669*^9, 3.8961735122691727`*^9}, {3.896173888238743*^9, 
   3.8961739120651283`*^9}, {3.896173997797559*^9, 3.8961739989235287`*^9}, {
   3.896176067570005*^9, 3.896176070393202*^9}, {3.8962376588776197`*^9, 
   3.896237687127656*^9}, {3.8962464909244213`*^9, 3.896246501581777*^9}, 
   3.896246540808484*^9, {3.896247045309177*^9, 3.896247045701437*^9}, {
   3.896247527412057*^9, 3.8962475341707163`*^9}, {3.89624861772556*^9, 
   3.8962486304574547`*^9}, {3.896253810076376*^9, 3.896253815154484*^9}, 
   3.896254206287826*^9, {3.8962617901166*^9, 3.8962618403609867`*^9}, {
   3.89685511427064*^9, 3.896855131312875*^9}, {3.896855180388139*^9, 
   3.896855185424788*^9}, {3.896855472552267*^9, 3.89685547321246*^9}},
 CellLabel->"In[35]:=",ExpressionUUID->"4028668f-5ca7-49c4-b7c2-50b6e30307c6"]
}, Closed]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"(*", 
  "\"\<`IterativeFindMinPoint function executes an iterative local \
optimization process that adjusts the search area and updates the initial \
point,until the Euclidean distance from the optimized point to the target \
value is less than a specified tolerance.\>\"", "*)"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10002.},
 CellChangeTimes->{{3.8961736563128*^9, 3.896173676439456*^9}, {
  3.8961738394591312`*^9, 3.89617385975569*^9}, {3.896259400720231*^9, 
  3.89625940768017*^9}, {3.896259978382813*^9, 3.896259978738475*^9}},
 CellLabel->"In[36]:=",ExpressionUUID->"04c1184a-4e5b-4819-87f6-aa4320f22543"],

Cell[BoxData[
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"IterativeFindMinPoint", "[", 
     RowBox[{
     "initialPointInput_", ",", "gridDensity_", ",", "deltaInput_", ",", 
      "target_", ",", "tolerance_", ",", "testFunc_"}], "]"}], ":=", 
    RowBox[{"Module", "[", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{
        RowBox[{"oldNorm", "=", "Infinity"}], ",", 
        RowBox[{"newNorm", "=", "Infinity"}], ",", 
        RowBox[{"normTolerance", "=", "tolerance"}], ",", "point", ",", 
        RowBox[{"initialPoint", "=", "initialPointInput"}], ",", 
        RowBox[{"delta", "=", "deltaInput"}]}], "}"}], ",", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"(*", 
       RowBox[{
       "Initialize", " ", "newNorm", " ", "for", " ", "the", " ", "while", 
        " ", "loop", " ", "condition"}], "*)"}], "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"newNorm", "=", "Infinity"}], ";", "\n", "\[IndentingNewLine]", 
       RowBox[{"While", "[", 
        RowBox[{
         RowBox[{"(", 
          RowBox[{"newNorm", ">=", "tolerance"}], ")"}], ",", 
         RowBox[{"(*", 
          RowBox[{
          "Find", " ", "optimized", " ", "point", " ", "and", " ", "its", " ",
            "Euclidean", " ", "distance", " ", "from", " ", "target"}], 
          "*)"}], "\[IndentingNewLine]", "\[IndentingNewLine]", 
         RowBox[{
          RowBox[{
           RowBox[{"{", 
            RowBox[{"point", ",", "newNorm"}], "}"}], "=", 
           RowBox[{"findMinPoint", "[", 
            RowBox[{
            "initialPoint", ",", "gridDensity", ",", "delta", ",", "target", 
             ",", "testFunc"}], "]"}]}], ";", "\[IndentingNewLine]", 
          "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]",
           "\[IndentingNewLine]", 
          RowBox[{"If", "[", 
           RowBox[{
            RowBox[{
             RowBox[{"newNorm", "-", "oldNorm"}], ">=", "0"}], ",", 
            "\[IndentingNewLine]", 
            RowBox[{"(*", 
             RowBox[{
              RowBox[{
              "If", " ", "the", " ", "Euclidean", " ", "distance", " ", 
               "increases"}], ",", 
              RowBox[{
              "reduce", " ", "search", " ", "interval", " ", "size"}]}], 
             "*)"}], "\[IndentingNewLine]", 
            RowBox[{
             RowBox[{"delta", "=", 
              RowBox[{"delta", "/", "10.0"}]}], ";"}], "\[IndentingNewLine]", 
            "\[IndentingNewLine]", ",", "\[IndentingNewLine]", 
            RowBox[{"(*", 
             RowBox[{
              RowBox[{
              "If", " ", "the", " ", "Euclidean", " ", "distance", " ", 
               "decreases", " ", "or", " ", "stays", " ", "the", " ", 
               "same"}], ",", 
              RowBox[{"update", " ", "the", " ", "initial", " ", "point"}]}], 
             "*)"}], "\[IndentingNewLine]", 
            RowBox[{
             RowBox[{"initialPoint", "=", "point"}], ";", 
             "\[IndentingNewLine]", 
             RowBox[{"oldNorm", "=", "newNorm"}], ";"}]}], 
           "\[IndentingNewLine]", "\[IndentingNewLine]", "]"}], ";"}]}], 
        "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
        "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", 
       "\[IndentingNewLine]", 
       RowBox[{"Remove", "[", 
        RowBox[{"normTolerance", ",", "initialPoint", ",", "delta"}], "]"}], 
       ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{"(*", 
        RowBox[{
        "Return", " ", "the", " ", "final", " ", "point", " ", "and", " ", 
         "its", " ", "Euclidean", " ", "distance", " ", "from", " ", "the", 
         " ", "target"}], "*)"}], "\[IndentingNewLine]", 
       RowBox[{"Return", "[", 
        RowBox[{"{", 
         RowBox[{"point", ",", "newNorm"}], "}"}], "]"}], ";"}]}], 
     "\[IndentingNewLine]", "]"}]}], ";"}], "\n", "\n", 
  RowBox[{"(*", 
   RowBox[{
    RowBox[{
    "This", " ", "code", " ", "iteratively", " ", "refines", " ", "an", " ", 
     "initial", " ", "guess", " ", "to", " ", "minimize", " ", "the", " ", 
     "Euclidean", " ", "distance", " ", "between", " ", "the", " ", "output", 
     " ", "of", " ", "a", " ", "test", " ", "function", " ", "and", " ", "a", 
     " ", "target", " ", 
     RowBox[{"value", ".", "The"}], " ", "findMinPoint", " ", "module", " ", 
     "is", " ", "used", " ", "in", " ", "each", " ", "iteration", " ", "to", 
     " ", "find", " ", "an", " ", "optimized", " ", 
     RowBox[{"point", ".", "If"}], " ", "the", " ", "Euclidean", " ", 
     "distance", " ", "increases", " ", "from", " ", "one", " ", "iteration", 
     " ", "to", " ", "the", " ", "next"}], ",", 
    RowBox[{
    "the", " ", "search", " ", "intervals", " ", "are", " ", "reduced", " ", 
     "by", " ", "a", " ", "factor", " ", "of", " ", "10", " ", "for", " ", 
     "finer", " ", 
     RowBox[{"precision", ".", "The"}], " ", "process", " ", "continues", " ",
      "until", " ", "the", " ", "change", " ", "in", " ", "Euclidean", " ", 
     "distance", " ", "between", " ", "two", " ", "consecutive", " ", 
     "iterations", " ", "is", " ", "less", " ", "than", " ", "a", " ", 
     "defined", " ", 
     RowBox[{"tolerance", "."}]}]}], "*)"}], "\[IndentingNewLine]"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10002.},
 CellChangeTimes->{{3.896172938277594*^9, 3.896172944609015*^9}, {
   3.8961730369771967`*^9, 3.896173043818164*^9}, {3.896173368919876*^9, 
   3.896173369173224*^9}, {3.896173599047578*^9, 3.896173645440854*^9}, 
   3.8961736764404783`*^9, 3.896173786140497*^9, 3.896173839459771*^9, {
   3.896174033683427*^9, 3.89617405150107*^9}, {3.896174977163761*^9, 
   3.896174987571039*^9}, {3.896175038250359*^9, 3.8961750419992228`*^9}, {
   3.896175093924571*^9, 3.8961750958362503`*^9}, {3.896175139941416*^9, 
   3.8961751596130047`*^9}, {3.896175346860444*^9, 3.896175360910665*^9}, {
   3.896175403836841*^9, 3.896175410788081*^9}, 3.896175544738276*^9, {
   3.896175586405672*^9, 3.8961756206316967`*^9}, 3.896175691067607*^9, {
   3.896175761258349*^9, 3.89617576582979*^9}, 3.8961758630975246`*^9, {
   3.8962466725626163`*^9, 3.89624668684403*^9}, {3.8962470518045483`*^9, 
   3.896247052251952*^9}, 3.896247195872017*^9, 3.8962476481413527`*^9, {
   3.8962477449054623`*^9, 3.896247748841411*^9}, 3.89624839674009*^9, {
   3.896253822932002*^9, 3.896253835423149*^9}, {3.89625940072033*^9, 
   3.896259420958378*^9}, {3.896259466112908*^9, 3.896259466327797*^9}, {
   3.896259855763979*^9, 3.896259859546533*^9}, {3.896259960849718*^9, 
   3.8962599751641417`*^9}, {3.8968550374814787`*^9, 3.896855063005486*^9}, {
   3.89685540928271*^9, 3.896855417117775*^9}, 3.8968554635077868`*^9, 
   3.896939826648134*^9, {3.8988463634750977`*^9, 3.898846390443611*^9}, {
   3.898847015371516*^9, 3.898847016573297*^9}},
 CellLabel->"In[37]:=",ExpressionUUID->"35309c83-b686-4210-91d8-44951d75966a"]
}, Closed]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{
   RowBox[{"Insert", " ", "Columns"}], " ", "-", " ", 
   RowBox[{
   "helper", " ", "method", " ", "for", " ", "exporting", " ", "data"}]}], 
  "*)"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10003.},
 CellChangeTimes->{{3.773120665285272*^9, 3.7731206818026237`*^9}, 
   3.899263544645862*^9},
 CellLabel->"In[38]:=",ExpressionUUID->"d4d56de5-aea6-4664-8f05-d7094dca4bbf"],

Cell[BoxData[
 RowBox[{
  RowBox[{
   RowBox[{"columnAttach", "[", "ak__List", "]"}], ":=", 
   RowBox[{
    RowBox[{
     RowBox[{"Join", "[", 
      RowBox[{"##", ",", "2"}], "]"}], "&"}], "@@", 
    RowBox[{"Replace", "[", 
     RowBox[{
      RowBox[{"{", "ak", "}"}], ",", 
      RowBox[{
       RowBox[{"v_", "?", "VectorQ"}], "\[RuleDelayed]", 
       RowBox[{"List", "/@", "v"}]}], ",", "1"}], "]"}]}]}], ";"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10003.},
 CellChangeTimes->{3.773120681807624*^9, 3.8992635446462183`*^9},
 CellLabel->"In[39]:=",ExpressionUUID->"9823bb01-8120-48db-b1ee-b75f73ab1bd2"]
}, Closed]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{
   RowBox[{"`exportCalibvals", "'"}], " ", "-", " ", 
   "\"\<The code prepares calibrated parameters for export\>\""}], 
  "*)"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.},
 CellChangeTimes->{{3.89918447924575*^9, 3.899184496903994*^9}, {
  3.899802489135614*^9, 3.899802491010461*^9}, {3.899802716568302*^9, 
  3.899802725294046*^9}},
 CellLabel->"In[40]:=",ExpressionUUID->"4c6dd1a5-99cd-4b74-bd1c-b502ad6e80f8"],

Cell[BoxData[
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"exportCalibvals", "[", 
     RowBox[{"allParms_", ",", "ans_", ",", "inputData_"}], "]"}], ":=", 
    RowBox[{"Module", "[", 
     RowBox[{
      RowBox[{"{", "\[IndentingNewLine]", "rnd", "\[IndentingNewLine]", "}"}],
       ",", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{
        RowBox[{"rnd", "[", "n_", "]"}], ":=", 
        RowBox[{"NumberForm", "[", 
         RowBox[{"n", ",", 
          RowBox[{"{", 
           RowBox[{"5", ",", "3"}], "}"}]}], "]"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"{", 
        RowBox[{
         RowBox[{"{", 
          RowBox[{"\"\<D0\>\"", ",", "1", ",", "\"\<\>\""}], "}"}], ",", 
         "\[IndentingNewLine]", 
         RowBox[{"{", 
          RowBox[{"\"\<N0\>\"", ",", "0.37", ",", "\"\<\>\""}], "}"}], ",", 
         "\[IndentingNewLine]", 
         RowBox[{"{", 
          RowBox[{"\"\<gDss\>\"", ",", 
           RowBox[{"rnd", "[", 
            SuperscriptBox[
             RowBox[{"(", 
              RowBox[{"gDss", "/.", "allParms"}], ")"}], 
             FractionBox["1", "25"]], "]"}], ",", "\"\<\>\""}], "}"}], ",", 
         "\[IndentingNewLine]", 
         RowBox[{"{", 
          RowBox[{"\"\<ktilde0\>\"", ",", 
           RowBox[{"rnd", "[", 
            RowBox[{
             SubscriptBox["ktilde", "0"], "/.", 
             RowBox[{"ans", "[", 
              RowBox[{"[", "4", "]"}], "]"}]}], "]"}], ",", "\"\<\>\""}], 
          "}"}], ",", "\[IndentingNewLine]", 
         RowBox[{"{", 
          RowBox[{"\"\<ass\>\"", ",", 
           RowBox[{"rnd", "[", 
            RowBox[{"ass", "/.", "allParms"}], "]"}], ",", "\"\<\>\""}], 
          "}"}], ",", "\[IndentingNewLine]", 
         RowBox[{"{", 
          RowBox[{"\"\<ktildess\>\"", ",", 
           RowBox[{"rnd", "[", 
            RowBox[{"ktildess", "/.", "allParms"}], "]"}], ",", "\"\<\>\""}], 
          "}"}], ",", "\[IndentingNewLine]", 
         RowBox[{"{", 
          RowBox[{"\"\<Piess\>\"", ",", 
           RowBox[{"rnd", "[", 
            RowBox[{"Piess", "/.", "allParms"}], "]"}], ",", "\"\<\>\""}], 
          "}"}], ",", "\[IndentingNewLine]", 
         RowBox[{"{", 
          RowBox[{"\"\<n\>\"", ",", 
           RowBox[{"rnd", "[", 
            RowBox[{"nTypes", "/.", "allParms"}], "]"}], ",", "\"\<\>\""}], 
          "}"}], ",", "\[IndentingNewLine]", 
         RowBox[{"{", 
          RowBox[{"\"\<time\>\"", ",", 
           RowBox[{"rnd", "[", 
            RowBox[{"time", "/.", "allParms"}], "]"}], ",", "\"\<\>\""}], 
          "}"}], ",", "\[IndentingNewLine]", 
         RowBox[{"{", 
          RowBox[{"\"\<alpha\>\"", ",", 
           RowBox[{"rnd", "[", 
            RowBox[{"\[Alpha]", "/.", "allParms"}], "]"}], ",", 
           RowBox[{"NumberForm", "[", 
            RowBox[{
             RowBox[{"100", "*", 
              RowBox[{"(", 
               RowBox[{"lrconssh", "/.", "inputData"}], ")"}]}], ",", "3"}], 
            "]"}]}], "}"}], ",", "\[IndentingNewLine]", 
         RowBox[{"{", 
          RowBox[{"\"\<betamax\>\"", ",", 
           RowBox[{"rnd", "[", 
            RowBox[{"betamax", "/.", "allParms"}], "]"}], ",", "\"\<\>\""}], 
          "}"}], ",", "\[IndentingNewLine]", 
         RowBox[{"{", 
          RowBox[{"\"\<betaI\>\"", ",", 
           RowBox[{"rnd", "[", 
            RowBox[{
             SubscriptBox["\[Beta]", "1"], "/.", "allParms"}], "]"}], ",", 
           "\"\<\>\""}], "}"}], ",", "\[IndentingNewLine]", 
         RowBox[{"{", 
          RowBox[{"\"\<nu\>\"", ",", 
           RowBox[{"rnd", "[", 
            RowBox[{"\[Nu]", "/.", "allParms"}], "]"}], ",", "\"\<\>\""}], 
          "}"}], ",", "\[IndentingNewLine]", 
         RowBox[{"{", 
          RowBox[{"\"\<gamma\>\"", ",", 
           RowBox[{"NumberForm", "[", 
            RowBox[{
             RowBox[{"\[Gamma]", "/.", "allParms"}], ",", 
             RowBox[{"{", 
              RowBox[{"3", ",", "1"}], "}"}]}], "]"}], ",", 
           RowBox[{"NumberForm", "[", 
            RowBox[{
             RowBox[{"100", "*", 
              RowBox[{"(", 
               RowBox[{"lrintr", "/.", "inputData"}], ")"}]}], ",", "3"}], 
            "]"}]}], "}"}], ",", "\[IndentingNewLine]", 
         RowBox[{"{", 
          RowBox[{"\"\<delta\>\"", ",", 
           RowBox[{"NumberForm", "[", 
            RowBox[{
             RowBox[{"delta", "/.", "allParms"}], ",", 
             RowBox[{"{", 
              RowBox[{"3", ",", "1"}], "}"}]}], "]"}], ",", 
           RowBox[{"stdevbeta", "/.", "inputData"}]}], "}"}], ",", 
         "\[IndentingNewLine]", 
         RowBox[{"{", 
          RowBox[{"\"\<inityear\>\"", ",", 
           RowBox[{"inityear", "/.", "allParms"}], ",", "\"\<\>\""}], "}"}], 
         ",", "\[IndentingNewLine]", 
         RowBox[{"{", 
          RowBox[{"\"\<currentyear\>\"", ",", 
           RowBox[{"currentyear", "/.", "allParms"}], ",", "\"\<\>\""}], 
          "}"}], ",", "\[IndentingNewLine]", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"\"\<gn\>\"", "<>", 
            RowBox[{"ToString", "[", 
             RowBox[{
              RowBox[{"(", 
               RowBox[{"gNCutoffs", "/.", "inputData"}], ")"}], "[", 
              RowBox[{"[", 
               RowBox[{"1", ",", "1"}], "]"}], "]"}], "]"}]}], ",", 
           RowBox[{"NumberForm", "[", 
            RowBox[{
             RowBox[{"100", "*", 
              RowBox[{"(", 
               RowBox[{
                RowBox[{
                 RowBox[{"(", 
                  RowBox[{"gNCutoffs", "/.", "inputData"}], ")"}], "[", 
                 RowBox[{"[", 
                  RowBox[{"1", ",", "2"}], "]"}], "]"}], "-", "1"}], ")"}]}], 
             ",", 
             RowBox[{"{", 
              RowBox[{"5", ",", "2"}], "}"}]}], "]"}], ",", "\"\<\>\""}], 
          "}"}], ",", "\[IndentingNewLine]", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"\"\<gn\>\"", "<>", 
            RowBox[{"ToString", "[", 
             RowBox[{
              RowBox[{"(", 
               RowBox[{"gNCutoffs", "/.", "inputData"}], ")"}], "[", 
              RowBox[{"[", 
               RowBox[{"2", ",", "1"}], "]"}], "]"}], "]"}]}], ",", 
           RowBox[{"NumberForm", "[", 
            RowBox[{
             RowBox[{"100", "*", 
              RowBox[{"(", 
               RowBox[{
                RowBox[{
                 RowBox[{"(", 
                  RowBox[{"gNCutoffs", "/.", "inputData"}], ")"}], "[", 
                 RowBox[{"[", 
                  RowBox[{"2", ",", "2"}], "]"}], "]"}], "-", "1"}], ")"}]}], 
             ",", 
             RowBox[{"{", 
              RowBox[{"5", ",", "2"}], "}"}]}], "]"}], ",", "\"\<\>\""}], 
          "}"}], ",", "\[IndentingNewLine]", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"\"\<gn\>\"", "<>", 
            RowBox[{"ToString", "[", 
             RowBox[{
              RowBox[{"(", 
               RowBox[{"gNCutoffs", "/.", "inputData"}], ")"}], "[", 
              RowBox[{"[", 
               RowBox[{"3", ",", "1"}], "]"}], "]"}], "]"}]}], ",", 
           RowBox[{"NumberForm", "[", 
            RowBox[{
             RowBox[{"100", "*", 
              RowBox[{"(", 
               RowBox[{
                RowBox[{
                 RowBox[{"(", 
                  RowBox[{"gNCutoffs", "/.", "inputData"}], ")"}], "[", 
                 RowBox[{"[", 
                  RowBox[{"3", ",", "2"}], "]"}], "]"}], "-", "1"}], ")"}]}], 
             ",", 
             RowBox[{"{", 
              RowBox[{"5", ",", "2"}], "}"}]}], "]"}], ",", "\"\<\>\""}], 
          "}"}], ",", "\[IndentingNewLine]", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"\"\<gd\>\"", "<>", 
            RowBox[{"ToString", "[", 
             RowBox[{
              RowBox[{"(", 
               RowBox[{"gDCutoffs", "/.", "inputData"}], ")"}], "[", 
              RowBox[{"[", 
               RowBox[{"1", ",", "1"}], "]"}], "]"}], "]"}]}], ",", 
           RowBox[{"NumberForm", "[", 
            RowBox[{
             RowBox[{"100", "*", 
              RowBox[{"(", 
               RowBox[{
                RowBox[{
                 RowBox[{"(", 
                  RowBox[{"gDCutoffs", "/.", "inputData"}], ")"}], "[", 
                 RowBox[{"[", 
                  RowBox[{"1", ",", "2"}], "]"}], "]"}], "-", "1"}], ")"}]}], 
             ",", 
             RowBox[{"{", 
              RowBox[{"5", ",", "2"}], "}"}]}], "]"}], ",", "\"\<\>\""}], 
          "}"}], ",", "\[IndentingNewLine]", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"\"\<gd\>\"", "<>", 
            RowBox[{"ToString", "[", 
             RowBox[{
              RowBox[{"(", 
               RowBox[{"gDCutoffs", "/.", "inputData"}], ")"}], "[", 
              RowBox[{"[", 
               RowBox[{"2", ",", "1"}], "]"}], "]"}], "]"}]}], ",", 
           RowBox[{"NumberForm", "[", 
            RowBox[{
             RowBox[{"100", "*", 
              RowBox[{"(", 
               RowBox[{
                RowBox[{
                 RowBox[{"(", 
                  RowBox[{"gDCutoffs", "/.", "inputData"}], ")"}], "[", 
                 RowBox[{"[", 
                  RowBox[{"2", ",", "2"}], "]"}], "]"}], "-", "1"}], ")"}]}], 
             ",", 
             RowBox[{"{", 
              RowBox[{"5", ",", "2"}], "}"}]}], "]"}], ",", "\"\<\>\""}], 
          "}"}], ",", "\[IndentingNewLine]", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"\"\<gd\>\"", "<>", 
            RowBox[{"ToString", "[", 
             RowBox[{
              RowBox[{"(", 
               RowBox[{"gDCutoffs", "/.", "inputData"}], ")"}], "[", 
              RowBox[{"[", 
               RowBox[{"3", ",", "1"}], "]"}], "]"}], "]"}]}], ",", 
           RowBox[{"NumberForm", "[", 
            RowBox[{
             RowBox[{"100", "*", 
              RowBox[{"(", 
               RowBox[{
                RowBox[{
                 RowBox[{"(", 
                  RowBox[{"gDCutoffs", "/.", "inputData"}], ")"}], "[", 
                 RowBox[{"[", 
                  RowBox[{"3", ",", "2"}], "]"}], "]"}], "-", "1"}], ")"}]}], 
             ",", 
             RowBox[{"{", 
              RowBox[{"5", ",", "2"}], "}"}]}], "]"}], ",", "\"\<\>\""}], 
          "}"}], ",", "\[IndentingNewLine]", 
         RowBox[{"{", 
          RowBox[{
          "\"\<Description\>\"", ",", 
           "\"\<The value column shows the calibrated parameters for the \
Model. The target column shows the value of targeted moments in the \
calibration\>\"", ",", "\"\<\>\""}], "}"}]}], "}"}]}]}], 
     "\[IndentingNewLine]", "]"}]}], ";"}], "\n"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.},
 CellChangeTimes->{{3.89918423566695*^9, 3.899184249955917*^9}, {
   3.8991843115086946`*^9, 3.89918434643965*^9}, {3.899184379355945*^9, 
   3.8991843846524973`*^9}, 3.8991844969046173`*^9, {3.899191367214095*^9, 
   3.899191391765724*^9}, 3.899193089083439*^9, {3.8991936843319817`*^9, 
   3.899193687008009*^9}, {3.8991937581801767`*^9, 3.8991938590554037`*^9}, {
   3.899802486131115*^9, 3.899802486725914*^9}, {3.8998026885326567`*^9, 
   3.89980269807275*^9}, {3.899804137961872*^9, 3.899804138551076*^9}, {
   3.8998866787611647`*^9, 3.899886695643605*^9}, 3.899886745245953*^9, 
   3.8998867865530977`*^9, {3.899886869697055*^9, 3.899886873878489*^9}, {
   3.899887274719005*^9, 3.899887333585919*^9}, {3.899887725651257*^9, 
   3.8998877516643763`*^9}, {3.8998877887033*^9, 3.8998878093171253`*^9}, {
   3.899890242141692*^9, 3.8998902482763767`*^9}, {3.899890281732047*^9, 
   3.89989028431809*^9}, {3.899890401374999*^9, 3.89989040780626*^9}, {
   3.8998907529388227`*^9, 3.899890752999651*^9}, {3.899890817369791*^9, 
   3.899890817471243*^9}},
 CellLabel->"In[41]:=",ExpressionUUID->"d8f390d8-9205-42d3-9420-ea4a9b6c84c0"]
}, Closed]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{
   RowBox[{"computeValuesToExport", "[", 
    RowBox[{"ans_", ",", "allParms_"}], "]"}], " ", "-", " ", 
   RowBox[{
   "take", " ", "model", " ", "outputs", " ", "and", " ", "generates", " ", 
    "data", " ", "to", " ", "export"}]}], "*)"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.},
 CellChangeTimes->{{3.899459963911758*^9, 3.899459986714291*^9}, 
   3.8994601304786873`*^9, {3.900040249077901*^9, 3.9000402565008297`*^9}, {
   3.900040455983308*^9, 3.9000404861671867`*^9}, 3.9030691134403353`*^9},
 CellLabel->"In[42]:=",ExpressionUUID->"1b626701-011b-4c14-9f31-636e5a325f91"],

Cell[BoxData[
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"computeValuesToExport", "[", 
     RowBox[{"ans_", ",", "allParms_"}], "]"}], ":=", 
    RowBox[{"Module", "[", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{
       "a", ",", "d", ",", "gd", ",", "gn", ",", "gy", ",", "p", ",", "year", 
        ",", "pop", ",", "gdppc", ",", "fert", ",", "r", ",", "savrate", ",", 
        "q", ",", "conspc", ",", "cpiLaspeyres", ",", "cpiPaasche", ",", 
        "cpiFisher", ",", "qrelLasp", ",", "qrelPaas", ",", "qrelFish", ",", 
        "columnAttach"}], "}"}], ",", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{
        RowBox[{"columnAttach", "[", "ak__List", "]"}], ":=", 
        RowBox[{
         RowBox[{
          RowBox[{"Join", "[", 
           RowBox[{"##", ",", "2"}], "]"}], "&"}], "@@", 
         RowBox[{"Replace", "[", 
          RowBox[{
           RowBox[{"{", "ak", "}"}], ",", 
           RowBox[{
            RowBox[{"v_", "?", "VectorQ"}], "\[RuleDelayed]", 
            RowBox[{"List", "/@", "v"}]}], ",", "1"}], "]"}]}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"a", "=", 
        RowBox[{
         RowBox[{"Rest", "[", 
          RowBox[{"ans", "[", 
           RowBox[{"[", 
            RowBox[{"2", ",", "All", ",", "2"}], "]"}], "]"}], "]"}], "[", 
         RowBox[{"[", 
          RowBox[{"1", ";;", "29"}], "]"}], "]"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"d", "=", 
        RowBox[{
         RowBox[{"ans", "[", 
          RowBox[{"[", 
           RowBox[{"6", ",", "All", ",", "2"}], "]"}], "]"}], "[", 
         RowBox[{"[", 
          RowBox[{"1", ";;", "29"}], "]"}], "]"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"gd", "=", 
        RowBox[{
         FractionBox[
          RowBox[{"Rest", "[", 
           RowBox[{"Prepend", "[", 
            RowBox[{
             RowBox[{"ans", "[", 
              RowBox[{"[", 
               RowBox[{"6", ",", "All", ",", "2"}], "]"}], "]"}], ",", "1"}], 
            "]"}], "]"}], 
          RowBox[{"Most", "[", 
           RowBox[{"Prepend", "[", 
            RowBox[{
             RowBox[{"ans", "[", 
              RowBox[{"[", 
               RowBox[{"6", ",", "All", ",", "2"}], "]"}], "]"}], ",", "1"}], 
            "]"}], "]"}]], "[", 
         RowBox[{"[", 
          RowBox[{"1", ";;", "29"}], "]"}], "]"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"p", "=", 
        RowBox[{"Rest", "[", 
         RowBox[{"Pie", "/.", "allParms"}], "]"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"gn", "=", 
        RowBox[{
         FractionBox[
          RowBox[{"Rest", "[", 
           RowBox[{"Prepend", "[", 
            RowBox[{
             RowBox[{"ans", "[", 
              RowBox[{"[", 
               RowBox[{"3", ",", "All", ",", "2"}], "]"}], "]"}], ",", 
             ".3614339"}], "]"}], "]"}], 
          RowBox[{"Most", "[", 
           RowBox[{"Prepend", "[", 
            RowBox[{
             RowBox[{"ans", "[", 
              RowBox[{"[", 
               RowBox[{"3", ",", "All", ",", "2"}], "]"}], "]"}], ",", 
             ".3614339"}], "]"}], "]"}]], "[", 
         RowBox[{"[", 
          RowBox[{"1", ";;", "29"}], "]"}], "]"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"year", "=", 
        RowBox[{"Table", "[", 
         RowBox[{
          RowBox[{
           RowBox[{"(", 
            RowBox[{
             RowBox[{"t", "*", "25"}], "+", "inityear"}], ")"}], "/.", 
           "allParms"}], ",", 
          RowBox[{"{", 
           RowBox[{"t", ",", "0", ",", "28"}], "}"}]}], "]"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"pop", "=", 
        RowBox[{
         RowBox[{"ans", "[", 
          RowBox[{"[", 
           RowBox[{"3", ",", "All", ",", "2"}], "]"}], "]"}], "[", 
         RowBox[{"[", 
          RowBox[{"1", ";;", "29"}], "]"}], "]"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"gdppc", "=", 
        RowBox[{
         RowBox[{"Rest", "[", 
          RowBox[{"ans", "[", 
           RowBox[{"[", 
            RowBox[{"7", ",", "All", ",", "2"}], "]"}], "]"}], "]"}], "[", 
         RowBox[{"[", 
          RowBox[{"1", ";;", "29"}], "]"}], "]"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"gdppc", "=", 
        FractionBox["gdppc", 
         RowBox[{"gdppc", "[", 
          RowBox[{"[", "21", "]"}], "]"}]]}], ";", "\[IndentingNewLine]", 
       RowBox[{"gy", "=", 
        RowBox[{
         FractionBox[
          RowBox[{"Rest", "[", 
           RowBox[{"ans", "[", 
            RowBox[{"[", 
             RowBox[{"7", ",", "All", ",", "2"}], "]"}], "]"}], "]"}], 
          RowBox[{"Most", "[", 
           RowBox[{"ans", "[", 
            RowBox[{"[", 
             RowBox[{"7", ",", "All", ",", "2"}], "]"}], "]"}], "]"}]], "[", 
         RowBox[{"[", 
          RowBox[{"1", ";;", "29"}], "]"}], "]"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"fert", "=", 
        RowBox[{
         RowBox[{"ans", "[", 
          RowBox[{"[", 
           RowBox[{"11", ",", "All", ",", "2"}], "]"}], "]"}], "[", 
         RowBox[{"[", 
          RowBox[{"1", ";;", "29"}], "]"}], "]"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"r", "=", 
        RowBox[{"100", "*", 
         RowBox[{
          RowBox[{"(", 
           RowBox[{
            SuperscriptBox[
             RowBox[{"ans", "[", 
              RowBox[{"[", 
               RowBox[{"1", ",", "All", ",", "2"}], "]"}], "]"}], 
             FractionBox["1", "25"]], "-", "1"}], ")"}], "[", 
          RowBox[{"[", 
           RowBox[{"1", ";;", "29"}], "]"}], "]"}]}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"savrate", "=", 
        RowBox[{"100", "*", 
         RowBox[{
          RowBox[{"ans", "[", 
           RowBox[{"[", 
            RowBox[{"10", ",", "All", ",", "2"}], "]"}], "]"}], "[", 
          RowBox[{"[", 
           RowBox[{"1", ";;", "29"}], "]"}], "]"}]}]}], ";", 
       "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{"q", "=", 
        RowBox[{"(", 
         RowBox[{
          RowBox[{"a", "*", 
           SuperscriptBox["d", 
            FractionBox["1", 
             RowBox[{"1", "-", "\[Nu]"}]]]}], "/.", "allParms"}], ")"}]}], 
       ";", "\[IndentingNewLine]", 
       RowBox[{"conspc", "=", 
        FractionBox[
         RowBox[{
          RowBox[{"(", 
           RowBox[{
            RowBox[{"pop", "*", 
             SuperscriptBox["d", 
              FractionBox["1", 
               RowBox[{"1", "-", "\[Nu]"}]]]}], "/.", "allParms"}], ")"}], 
          "*", 
          RowBox[{
           RowBox[{"ans", "[", 
            RowBox[{"[", 
             RowBox[{"8", ",", "All", ",", "2"}], "]"}], "]"}], "[", 
           RowBox[{"[", 
            RowBox[{"1", ";;", "29"}], "]"}], "]"}]}], "pop"]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"cpiLaspeyres", "=", 
        FractionBox[
         RowBox[{
          RowBox[{"1", "*", 
           RowBox[{"conspc", "[", 
            RowBox[{"[", "29", "]"}], "]"}]}], "+", 
          RowBox[{"q", "*", 
           RowBox[{"fert", "[", 
            RowBox[{"[", "29", "]"}], "]"}]}]}], 
         RowBox[{
          RowBox[{"1", "*", 
           RowBox[{"conspc", "[", 
            RowBox[{"[", "29", "]"}], "]"}]}], "+", 
          RowBox[{
           RowBox[{"q", "[", 
            RowBox[{"[", "29", "]"}], "]"}], "*", 
           RowBox[{"fert", "[", 
            RowBox[{"[", "29", "]"}], "]"}]}]}]]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"cpiPaasche", "=", 
        FractionBox[
         RowBox[{
          RowBox[{"1", "*", "conspc"}], "+", 
          RowBox[{"q", "*", "fert"}]}], 
         RowBox[{
          RowBox[{"1", "*", "conspc"}], "+", 
          RowBox[{
           RowBox[{"q", "[", 
            RowBox[{"[", "29", "]"}], "]"}], "*", "fert"}]}]]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"cpiFisher", "=", 
        RowBox[{"Sqrt", "[", 
         RowBox[{"cpiLaspeyres", "*", "cpiPaasche"}], "]"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"qrelLasp", "=", 
        FractionBox[
         FractionBox["q", "cpiLaspeyres"], 
         RowBox[{
          FractionBox["q", "cpiLaspeyres"], "[", 
          RowBox[{"[", "21", "]"}], "]"}]]}], ";", "\[IndentingNewLine]", 
       RowBox[{"qrelPaas", "=", 
        FractionBox[
         FractionBox["q", "cpiPaasche"], 
         RowBox[{
          FractionBox["q", "cpiPaasche"], "[", 
          RowBox[{"[", "21", "]"}], "]"}]]}], ";", "\[IndentingNewLine]", 
       RowBox[{"qrelFish", "=", 
        FractionBox[
         FractionBox["q", "cpiFisher"], 
         RowBox[{
          FractionBox["q", "cpiFisher"], "[", 
          RowBox[{"[", "21", "]"}], "]"}]]}], ";", "\[IndentingNewLine]", 
       "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{"Insert", "[", 
        RowBox[{
         RowBox[{"columnAttach", "[", "\[IndentingNewLine]", 
          RowBox[{
          "year", ",", "a", ",", "d", ",", "gd", ",", "p", ",", "r", ",", 
           "pop", ",", "gn", ",", "gdppc", ",", "gy", ",", "fert", ",", 
           "qrelLasp", ",", "qrelPaas", ",", "qrelFish", ",", "savrate"}], 
          "]"}], ",", "\[IndentingNewLine]", 
         RowBox[{"{", 
          RowBox[{
          "\"\<year\>\"", ",", "\"\<a\>\"", ",", "\"\<D\>\"", ",", 
           "\"\<gD\>\"", ",", "\"\<pie\>\"", ",", "\"\<r\>\"", ",", 
           "\"\<pop\>\"", ",", "\"\<gn\>\"", ",", "\"\<gdppc\>\"", ",", 
           "\"\<gy\>\"", ",", "\"\<fert\>\"", ",", "\"\<qrelLasp\>\"", ",", 
           "\"\<qrelPaas\>\"", ",", "\"\<qrelFish\>\"", ",", 
           "\"\<savrate\>\""}], "\[IndentingNewLine]", "}"}], ",", "1"}], 
        "]"}]}]}], "\[IndentingNewLine]", "\[IndentingNewLine]", "]"}]}], 
   ";"}], "\n"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.},
 CellChangeTimes->{{3.899459860822661*^9, 3.899459864746266*^9}, {
   3.8994598967868013`*^9, 3.899459914307485*^9}, {3.89946001938579*^9, 
   3.89946002053351*^9}, {3.899460091801093*^9, 3.899460130479474*^9}, {
   3.899546268078609*^9, 3.899546274488064*^9}, {3.899547123733839*^9, 
   3.899547138351362*^9}, {3.8995478754611883`*^9, 3.899547878040628*^9}, {
   3.89987610804522*^9, 3.899876124772356*^9}, {3.899876176671767*^9, 
   3.8998761806446457`*^9}, {3.90004014650772*^9, 3.900040156335149*^9}, {
   3.900040222511093*^9, 3.90004025650173*^9}, {3.9000403481195383`*^9, 
   3.9000403631219788`*^9}, {3.900047730828087*^9, 3.900047733268674*^9}, 
   3.902809831153138*^9, 3.9028105064901333`*^9, {3.902819224728627*^9, 
   3.902819297307766*^9}, 3.902819537677773*^9},
 CellLabel->"In[43]:=",ExpressionUUID->"b2a39932-4785-480a-8701-3c34a4ca851f"]
}, Closed]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{
   RowBox[{
    RowBox[{
     RowBox[{"robustness", "[", 
      RowBox[{"inputData_", ",", "ansFull_"}], "]"}], " ", "--"}], " ", 
    "Vary", " ", "gamma", " ", "and", " ", "delta", " ", 
    RowBox[{"(", "respectively", ")"}], " ", "in", " ", "the", " ", "main", 
    " ", "model"}], ",", " ", 
   RowBox[{
   "whilst", " ", "recalibrating", " ", "the", " ", "other", " ", "paramter", 
    " ", "to", " ", "match", " ", "the", " ", "interest", " ", "rate", " ", 
    "in", " ", "1325", " ", "and", " ", "then", " ", "see", " ", "what", " ", 
    "fractino", " ", "of", " ", "variance", " ", "in", " ", "2000", " ", 
    "can", " ", "be", " ", "explained", " ", "by", " ", "the", " ", "model", 
    " ", "and", " ", "the", " ", "role", " ", "that", " ", "selection", " ", 
    "plays", " ", "over", " ", "the", " ", "entire", " ", "period", " ", 
    "for", " ", "each", " ", "set", " ", "of", " ", "parameter", " ", 
    "values"}]}], "*)"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.},
 CellChangeTimes->{{3.9027491581908283`*^9, 3.902749163994308*^9}, {
   3.90274919436226*^9, 3.902749203781888*^9}, {3.90274929252538*^9, 
   3.9027493887014236`*^9}, 3.90274957300998*^9},
 CellLabel->"In[44]:=",ExpressionUUID->"9dd08808-69ae-40dd-a965-6c90fe2be12e"],

Cell[BoxData[
 RowBox[{
  RowBox[{
   RowBox[{"robustness", "[", 
    RowBox[{"inputData_", ",", "ansFull_"}], "]"}], ":=", 
   RowBox[{"Module", "[", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{
      "calibVals", ",", "gn", ",", "gd", ",", "gamma", ",", "selection", ",", 
       "R", ",", "RHomo", ",", "RFull1325", ",", "varyDelta", ",", 
       "varyGamma", ",", "vartest", ",", "selectionContribution", ",", 
       "varyGammaToExport", ",", "varyDeltaToExport"}], "}"}], 
     "\[IndentingNewLine]", ",", "\[IndentingNewLine]", "\[IndentingNewLine]",
      "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"calibVals", "=", 
       RowBox[{"calibration", "[", "inputData", "]"}]}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{"gn", "=", 
       RowBox[{
        FractionBox[
         RowBox[{
          RowBox[{"Rest", "[", 
           RowBox[{".3614339", "*", 
            RowBox[{"smoothedLevelsFromGrowth", "[", 
             RowBox[{
              RowBox[{"(", 
               RowBox[{"gNCutoffs", "/.", "inputData"}], ")"}], ",", 
              RowBox[{
               RowBox[{"(", 
                RowBox[{"inityear", "/.", "inputData"}], ")"}], "-", "25"}], 
              ",", 
              RowBox[{
               RowBox[{"(", 
                RowBox[{"currentyear", "+", "gNyearsFuture"}], ")"}], "/.", 
               "inputData"}]}], "]"}]}], "]"}], "[", 
          RowBox[{"[", 
           RowBox[{"All", ",", "2"}], "]"}], "]"}], 
         RowBox[{
          RowBox[{"Most", "[", 
           RowBox[{".3614339", "*", 
            RowBox[{"smoothedLevelsFromGrowth", "[", 
             RowBox[{
              RowBox[{"(", 
               RowBox[{"gNCutoffs", "/.", "inputData"}], ")"}], ",", 
              RowBox[{
               RowBox[{"(", 
                RowBox[{"inityear", "/.", "inputData"}], ")"}], "-", "25"}], 
              ",", 
              RowBox[{
               RowBox[{"(", 
                RowBox[{"currentyear", "+", "gNyearsFuture"}], ")"}], "/.", 
               "inputData"}]}], "]"}]}], "]"}], "[", 
          RowBox[{"[", 
           RowBox[{"All", ",", "2"}], "]"}], "]"}]], "[", 
        RowBox[{"[", 
         RowBox[{"1", ";;", "29"}], "]"}], "]"}]}], ";", 
      "\[IndentingNewLine]", "\n", 
      RowBox[{"gd", "=", 
       RowBox[{
        FractionBox[
         RowBox[{
          RowBox[{"Rest", "[", 
           RowBox[{"smoothedLevelsFromGrowth", "[", 
            RowBox[{
             RowBox[{"(", 
              RowBox[{"gDCutoffs", "/.", "inputData"}], ")"}], ",", 
             RowBox[{
              RowBox[{"(", 
               RowBox[{"inityear", "/.", "inputData"}], ")"}], "-", "25"}], 
             ",", 
             RowBox[{
              RowBox[{"(", 
               RowBox[{"currentyear", "+", "gDyearsFuture"}], ")"}], "/.", 
              "inputData"}]}], "]"}], "]"}], "[", 
          RowBox[{"[", 
           RowBox[{"All", ",", "2"}], "]"}], "]"}], 
         RowBox[{
          RowBox[{"Most", "[", 
           RowBox[{"smoothedLevelsFromGrowth", "[", 
            RowBox[{
             RowBox[{"(", 
              RowBox[{"gDCutoffs", "/.", "inputData"}], ")"}], ",", 
             RowBox[{
              RowBox[{"(", 
               RowBox[{"inityear", "/.", "inputData"}], ")"}], "-", "25"}], 
             ",", 
             RowBox[{
              RowBox[{"(", 
               RowBox[{"currentyear", "+", "gDyearsFuture"}], ")"}], "/.", 
              "inputData"}]}], "]"}], "]"}], "[", 
          RowBox[{"[", 
           RowBox[{"All", ",", "2"}], "]"}], "]"}]], "[", 
        RowBox[{"[", 
         RowBox[{"1", ";;", "29"}], "]"}], "]"}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"gamma", "[", "x_", "]"}], ":=", 
       SuperscriptBox["E", 
        RowBox[{"LogGamma", "[", "x", "]"}]]}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"selection", "[", 
        RowBox[{"\[Gamma]28_", ",", "\[Delta]_", ",", "\[Alpha]_"}], "]"}], ":=", 
       RowBox[{
        FractionBox[
         RowBox[{
          RowBox[{"Table", "[", 
           RowBox[{
            RowBox[{"\[Gamma]28", "-", "28", "+", "t", "-", "1"}], ",", 
            RowBox[{"{", 
             RowBox[{"t", ",", "0", ",", "28"}], "}"}]}], "]"}], "+", 
          "\[Delta]"}], 
         RowBox[{
          FractionBox[
           RowBox[{"1", "-", "\[Alpha]"}], 
           RowBox[{"(", 
            RowBox[{"\[Omega]", "+", 
             RowBox[{
              RowBox[{"(", 
               RowBox[{"1", "-", "\[Omega]"}], ")"}], 
              RowBox[{"(", 
               RowBox[{"Piess", "/.", "inputData"}], ")"}]}]}], ")"}]], " ", 
          RowBox[{"Table", "[", 
           RowBox[{
            RowBox[{"\[Gamma]28", "-", "28", "+", "t"}], ",", 
            RowBox[{"{", 
             RowBox[{"t", ",", "0", ",", "28"}], "}"}]}], "]"}]}]], "/.", 
        RowBox[{"{", 
         RowBox[{"\[Omega]", "\[Rule]", 
          RowBox[{"(", 
           RowBox[{"\[Omega]", "/.", "inputData"}], ")"}]}], "}"}]}]}], ";", 
      " ", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"R", "[", 
        RowBox[{"\[Gamma]28_", ",", "\[Delta]_", ",", "\[Alpha]_"}], "]"}], ":=", 
       RowBox[{
        SuperscriptBox[
         RowBox[{"(", 
          RowBox[{
           RowBox[{
            RowBox[{"selection", "[", 
             RowBox[{"\[Gamma]28", ",", "\[Delta]", ",", "\[Alpha]"}], "]"}], 
            FractionBox[
             RowBox[{"gn", "*", 
              SuperscriptBox["gd", 
               FractionBox["1", 
                RowBox[{"1", "-", "0.33"}]]]}], 
             RowBox[{"\[Omega]", "+", 
              RowBox[{
               RowBox[{"(", 
                RowBox[{"1", "-", "\[Omega]"}], ")"}], 
               RowBox[{
                RowBox[{"(", 
                 RowBox[{"Pie", "/.", "inputData"}], ")"}], "[", 
                RowBox[{"[", 
                 RowBox[{"1", ";;", "29"}], "]"}], "]"}]}]}]]}], "/.", 
           RowBox[{"{", 
            RowBox[{"\[Omega]", "\[Rule]", 
             RowBox[{"(", 
              RowBox[{"\[Omega]", "/.", "inputData"}], ")"}]}], "}"}]}], 
          ")"}], 
         FractionBox["1", "25"]], "-", "1"}]}], ";", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"RHomo", "[", 
        RowBox[{"\[Gamma]28_", ",", "\[Delta]_", ",", "\[Alpha]_"}], "]"}], ":=", 
       RowBox[{
        SuperscriptBox[
         RowBox[{"(", 
          RowBox[{
           RowBox[{
            RowBox[{
             RowBox[{"selection", "[", 
              RowBox[{"\[Gamma]28", ",", "\[Delta]", ",", "\[Alpha]"}], "]"}],
              "[", 
             RowBox[{"[", "29", "]"}], "]"}], "*", 
            FractionBox[
             RowBox[{"gn", "*", 
              SuperscriptBox["gd", 
               FractionBox["1", 
                RowBox[{"1", "-", "0.33"}]]]}], 
             RowBox[{"\[Omega]", "+", 
              RowBox[{
               RowBox[{"(", 
                RowBox[{"1", "-", "\[Omega]"}], ")"}], 
               RowBox[{
                RowBox[{"(", 
                 RowBox[{"Pie", "/.", "inputData"}], ")"}], "[", 
                RowBox[{"[", 
                 RowBox[{"1", ";;", "29"}], "]"}], "]"}]}]}]]}], "/.", 
           RowBox[{"{", 
            RowBox[{"\[Omega]", "\[Rule]", 
             RowBox[{"(", 
              RowBox[{"\[Omega]", "/.", "inputData"}], ")"}]}], "}"}]}], 
          ")"}], 
         FractionBox["1", "25"]], "-", "1"}]}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"RFull1325", "=", 
       RowBox[{
        RowBox[{"(", 
         RowBox[{
          SuperscriptBox[
           RowBox[{"ansFull", "[", 
            RowBox[{"[", 
             RowBox[{"1", ",", "All", ",", "2"}], "]"}], "]"}], 
           FractionBox["1", "25"]], "-", "1"}], ")"}], "[", 
        RowBox[{"[", "2", "]"}], "]"}]}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"varyDelta", "=", 
       RowBox[{"Table", "[", 
        RowBox[{
         RowBox[{"{", 
          RowBox[{
           RowBox[{"\[Gamma]", "/.", 
            RowBox[{
             RowBox[{"FindRoot", "[", 
              RowBox[{
               RowBox[{
                RowBox[{
                 RowBox[{"R", "[", 
                  RowBox[{"\[Gamma]", ",", "x", ",", 
                   RowBox[{"\[Alpha]", "/.", "calibVals"}]}], "]"}], "[", 
                 RowBox[{"[", "2", "]"}], "]"}], "==", "RFull1325"}], ",", 
               RowBox[{"{", 
                RowBox[{"\[Gamma]", ",", "30"}], "}"}]}], "]"}], "[", 
             RowBox[{"[", "1", "]"}], "]"}]}], ",", "x"}], "}"}], ",", 
         RowBox[{"{", 
          RowBox[{"x", ",", "21", ",", "250", ",", "1"}], "}"}]}], "]"}]}], 
      ";", "\[IndentingNewLine]", 
      RowBox[{"varyGamma", "=", 
       RowBox[{"Table", "[", 
        RowBox[{
         RowBox[{"{", 
          RowBox[{"x", ",", 
           RowBox[{"delta", "/.", 
            RowBox[{
             RowBox[{"FindRoot", "[", 
              RowBox[{
               RowBox[{
                RowBox[{
                 RowBox[{"R", "[", 
                  RowBox[{"x", ",", "delta", ",", 
                   RowBox[{"\[Alpha]", "/.", "calibVals"}]}], "]"}], "[", 
                 RowBox[{"[", "2", "]"}], "]"}], "==", "RFull1325"}], ",", 
               RowBox[{"{", 
                RowBox[{"delta", ",", "20"}], "}"}]}], "]"}], "[", 
             RowBox[{"[", "1", "]"}], "]"}]}]}], "}"}], ",", 
         RowBox[{"{", 
          RowBox[{"x", ",", "29.001", ",", "50.1", ",", "1"}], "}"}]}], 
        "]"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"vartest", "[", 
        RowBox[{"\[Gamma]_", ",", "delta_"}], "]"}], ":=", 
       RowBox[{
        RowBox[{"Sqrt", "[", 
         RowBox[{"(", 
          RowBox[{
           RowBox[{"-", 
            RowBox[{"(", 
             RowBox[{
              RowBox[{"(", 
               RowBox[{
                SuperscriptBox["betamax", 
                 RowBox[{"2", "/", "25"}]], " ", 
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{"Pie28", " ", 
                   RowBox[{"(", 
                    RowBox[{"2", "+", 
                    RowBox[{"25", " ", "\[Gamma]"}]}], ")"}], " ", 
                   RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "\[Omega]"}], ")"}]}], "-", 
                  RowBox[{"Piess", " ", 
                   RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "23"}], "+", 
                    RowBox[{"25", " ", "delta"}], "+", 
                    RowBox[{"25", " ", "\[Gamma]"}]}], ")"}], " ", 
                   RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "\[Omega]"}], ")"}]}], "+", 
                  RowBox[{"25", " ", 
                   RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "delta"}], ")"}], " ", 
                   "\[Omega]"}]}], ")"}], " ", 
                RowBox[{"SetPrecision", "[", 
                 RowBox[{
                  RowBox[{"gamma", "[", "delta", "]"}], ",", "2000"}], "]"}], 
                " ", "*", 
                RowBox[{"SetPrecision", "[", 
                 RowBox[{
                  RowBox[{"gamma", "[", 
                   RowBox[{
                    FractionBox["2", "25"], "+", "\[Gamma]"}], "]"}], ",", 
                  "2000"}], "]"}]}], ")"}], "/", 
              RowBox[{"(", 
               RowBox[{"25", " ", 
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{"Pie28", " ", "\[Gamma]"}], "+", 
                  RowBox[{"Piess", " ", 
                   RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "delta", "+", "\[Gamma]"}], 
                    ")"}], " ", 
                   RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "\[Omega]"}], ")"}]}], "+", 
                  "\[Omega]", "-", 
                  RowBox[{
                   RowBox[{"(", 
                    RowBox[{"delta", "+", 
                    RowBox[{"Pie28", " ", "\[Gamma]"}]}], ")"}], " ", 
                   "\[Omega]"}]}], ")"}], " ", 
                RowBox[{"SetPrecision", "[", 
                 RowBox[{
                  RowBox[{"Beta", "[", 
                   RowBox[{"\[Gamma]", ",", "delta"}], "]"}], ",", "2000"}], 
                 "]"}], "*", " ", 
                RowBox[{"SetPrecision", "[", 
                 RowBox[{
                  RowBox[{"gamma", "[", 
                   RowBox[{
                    FractionBox["2", "25"], "+", "delta", "+", "\[Gamma]"}], 
                   "]"}], ",", "2000"}], "]"}]}], ")"}]}], ")"}]}], "-", 
           SuperscriptBox[
            RowBox[{"(", 
             RowBox[{"-", 
              RowBox[{"(", 
               RowBox[{
                RowBox[{"(", 
                 RowBox[{
                  SuperscriptBox["betamax", 
                   RowBox[{"1", "/", "25"}]], " ", 
                  RowBox[{"(", 
                   RowBox[{
                    RowBox[{"Pie28", " ", 
                    RowBox[{"(", 
                    RowBox[{"1", "+", 
                    RowBox[{"25", " ", "\[Gamma]"}]}], ")"}], " ", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "\[Omega]"}], ")"}]}], "-", 
                    RowBox[{"Piess", " ", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "24"}], "+", 
                    RowBox[{"25", " ", "delta"}], "+", 
                    RowBox[{"25", " ", "\[Gamma]"}]}], ")"}], " ", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "\[Omega]"}], ")"}]}], "+", 
                    RowBox[{"25", " ", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "delta"}], ")"}], " ", 
                    "\[Omega]"}]}], ")"}], " ", 
                  RowBox[{"SetPrecision", "[", 
                   RowBox[{
                    RowBox[{"gamma", "[", "delta", "]"}], ",", "2000"}], 
                   "]"}], " ", "*", 
                  RowBox[{"SetPrecision", "[", 
                   RowBox[{
                    RowBox[{"gamma", "[", 
                    RowBox[{
                    FractionBox["1", "25"], "+", "\[Gamma]"}], "]"}], ",", 
                    "2000"}], "]"}]}], ")"}], "/", 
                RowBox[{"(", 
                 RowBox[{"25", " ", 
                  RowBox[{"(", 
                   RowBox[{
                    RowBox[{"Pie28", " ", "\[Gamma]"}], "+", 
                    RowBox[{"Piess", " ", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "delta", "+", "\[Gamma]"}], 
                    ")"}], " ", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "\[Omega]"}], ")"}]}], "+", 
                    "\[Omega]", "-", 
                    RowBox[{
                    RowBox[{"(", 
                    RowBox[{"delta", "+", 
                    RowBox[{"Pie28", " ", "\[Gamma]"}]}], ")"}], " ", 
                    "\[Omega]"}]}], ")"}], " ", 
                  RowBox[{"SetPrecision", "[", 
                   RowBox[{
                    RowBox[{"Beta", "[", 
                    RowBox[{"\[Gamma]", ",", "delta"}], "]"}], ",", "2000"}], 
                   "]"}], " ", "*", 
                  RowBox[{"SetPrecision", "[", 
                   RowBox[{
                    RowBox[{"gamma", "[", 
                    RowBox[{
                    FractionBox["1", "25"], "+", "delta", "+", "\[Gamma]"}], 
                    "]"}], ",", "2000"}], "]"}]}], ")"}]}], ")"}]}], ")"}], 
            "2"]}], ")"}], "]"}], "/.", 
        RowBox[{"Join", "[", 
         RowBox[{"inputData", ",", "calibVals"}], "]"}]}]}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"selectionContribution", "[", 
        RowBox[{"\[Gamma]_", ",", "delta_"}], "]"}], ":=", 
       RowBox[{"(", 
        RowBox[{
         RowBox[{"R", "[", 
          RowBox[{"\[Gamma]", ",", "delta", ",", 
           RowBox[{"\[Alpha]", "/.", "calibVals"}]}], "]"}], "-", 
         RowBox[{"(", 
          RowBox[{"RHomo", "[", 
           RowBox[{"\[Gamma]", ",", "delta", ",", 
            RowBox[{"\[Alpha]", "/.", "calibVals"}]}], "]"}], ")"}]}], 
        ")"}]}], ";", "\[IndentingNewLine]", 
      RowBox[{"(*", 
       RowBox[{
       "Calculates", " ", "what", " ", "fration", " ", "of", " ", "selection",
         " ", 
        RowBox[{"(", "0.0677", ")"}], " ", "and", " ", "variance", " ", 
        RowBox[{"(", 
         SuperscriptBox["0.0053", "2"], ")"}], " ", "is", " ", "explained"}], 
       "*)"}], "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"varyGammaToExport", "=", 
       RowBox[{"Prepend", "[", 
        RowBox[{
         RowBox[{"Transpose", "[", 
          RowBox[{"{", 
           RowBox[{
            RowBox[{
             RowBox[{"varyGamma", "[", 
              RowBox[{"[", 
               RowBox[{"All", ",", "1"}], "]"}], "]"}], "-", "28"}], ",", 
            RowBox[{
             FractionBox[
              RowBox[{
               RowBox[{"(", 
                RowBox[{"selectionContribution", "@@@", "varyGamma"}], ")"}], 
               "[", 
               RowBox[{"[", 
                RowBox[{"All", ",", "2"}], "]"}], "]"}], "0.0677"], "*", 
             "100"}], ",", 
            RowBox[{
             SuperscriptBox[
              RowBox[{"(", 
               FractionBox[
                RowBox[{"vartest", "@@@", "varyGamma"}], "0.0053"], ")"}], 
              "2"], "*", "100"}]}], "}"}], "]"}], ",", 
         RowBox[{"{", 
          RowBox[{
          "\"\<gamma0\>\"", ",", "\"\<selection\>\"", ",", 
           "\"\<variance\>\""}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", 
      RowBox[{"varyDeltaToExport", "=", 
       RowBox[{"Prepend", "[", 
        RowBox[{
         RowBox[{"Transpose", "[", 
          RowBox[{"{", 
           RowBox[{
            RowBox[{"varyDelta", "[", 
             RowBox[{"[", 
              RowBox[{"All", ",", "2"}], "]"}], "]"}], ",", 
            RowBox[{
             FractionBox[
              RowBox[{
               RowBox[{"(", 
                RowBox[{"selectionContribution", "@@@", "varyDelta"}], ")"}], 
               "[", 
               RowBox[{"[", 
                RowBox[{"All", ",", "2"}], "]"}], "]"}], "0.0677"], "*", 
             "100"}], ",", 
            RowBox[{
             SuperscriptBox[
              RowBox[{"(", 
               FractionBox[
                RowBox[{"vartest", "@@@", "varyDelta"}], "0.0053"], ")"}], 
              "2"], "*", "100"}]}], "}"}], "]"}], ",", 
         RowBox[{"{", 
          RowBox[{
          "\"\<delta\>\"", ",", "\"\<selection\>\"", ",", 
           "\"\<variance\>\""}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]",
       "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"{", 
       RowBox[{"varyGammaToExport", ",", "varyDeltaToExport"}], "}"}]}]}], 
    "\[IndentingNewLine]", "\[IndentingNewLine]", "]"}]}], ";"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.},
 CellChangeTimes->{{3.902749013975822*^9, 3.902749106237577*^9}, 
   3.902749573010331*^9, {3.902749672667514*^9, 3.90274968806001*^9}, {
   3.902749735420809*^9, 3.902749739540324*^9}, {3.902749775193858*^9, 
   3.902749864950152*^9}, {3.9027500372800207`*^9, 3.902750050647052*^9}, {
   3.9030691366010017`*^9, 3.9030691665332336`*^9}, {3.9030693077453527`*^9, 
   3.903069323931024*^9}, {3.903069363705832*^9, 3.903069372804225*^9}},
 CellLabel->"In[45]:=",ExpressionUUID->"ac217197-d25d-44b4-8f87-be34150c2da2"]
}, Closed]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{
   RowBox[{"compositionResults", "[", 
    RowBox[{
    "initialDistribution_", ",", "ans_", ",", "inputData_", ",", "allParms_", 
     ",", "foldername_String"}], "]"}], " ", "-", " ", 
   RowBox[{
   "Exports", " ", "the", " ", "distributions", " ", "of", " ", "capital", 
    " ", "and", " ", "labour", " ", "of", " ", "different", " ", "percentile",
     " ", "groups", " ", "over", " ", "time", " ", "as", " ", "well", " ", 
    "as", " ", "the", " ", "implied", " ", "societal", " ", 
    RowBox[{"patience", ".", " ", "It"}], " ", "also", " ", "exports", " ", 
    "the", " ", "Distribution", " ", "of", " ", "population", " ", "across", 
    " ", "different", " ", "betas", " ", "at", " ", "different", " ", 
    "points", " ", "in", " ", "time"}]}], " ", "*)"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.},
 CellChangeTimes->{{3.902821285442062*^9, 3.902821329084182*^9}, {
   3.902821387578219*^9, 3.902821394703335*^9}, 3.902821480611332*^9, 
   3.902821549197008*^9},
 CellLabel->"In[46]:=",ExpressionUUID->"a87a2642-37cf-4d61-8ed2-2f722873ca84"],

Cell[BoxData[
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"compositionResults", "[", 
     RowBox[{
     "initialDistribution_", ",", "ans_", ",", "inputData_", ",", "allParms_",
       ",", "foldername_String"}], "]"}], ":=", 
    RowBox[{"Module", "[", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{
       "timeparm", ",", "percentilesparm", ",", "j", ",", "NQmodel", ",", 
        "KQmodel", ",", "quantsols", ",", "bataparm", ",", "Piefunc", ",", 
        "en", ",", "omega", ",", "alpha", ",", "iyear", ",", "s0", ",", "b", 
        ",", "help", ",", "s", ",", "betas", ",", "dist", ",", "numbers", ",",
         "i", ",", "t", ",", "destination", ",", "qbounds", ",", "names", ",",
         "socbeta", ",", "namesq", ",", "year"}], "}"}], ",", 
      RowBox[{"(*", 
       RowBox[{"Existing", " ", "code", " ", "goes", " ", "here"}], "*)"}], 
      RowBox[{"(*", "...", "*)"}], "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"(*", 
       RowBox[{"Capital", " ", "and", " ", "population", " ", "quantiles"}], 
       "*)"}], "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"timeparm", "=", 
        RowBox[{"(", 
         RowBox[{"time", "/.", "allParms"}], ")"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"percentilesparm", "=", "8"}], ";", "\[IndentingNewLine]", 
       "\[IndentingNewLine]", 
       RowBox[{"For", "[", 
        RowBox[{
         RowBox[{"j", "=", "1"}], ",", 
         RowBox[{"j", "\[LessEqual]", "percentilesparm"}], ",", 
         RowBox[{"j", "++"}], ",", "\[IndentingNewLine]", 
         "\[IndentingNewLine]", 
         RowBox[{
          RowBox[{
           SubscriptBox["NQmodel", "j"], "=", 
           RowBox[{"Table", "[", 
            RowBox[{
             RowBox[{"SetPrecision", "[", 
              RowBox[{
               RowBox[{
                SubscriptBox[
                 RowBox[{"ToExpression", "[", 
                  RowBox[{"\"\<NQ\>\"", "<>", 
                   RowBox[{"ToString", "[", "j", "]"}]}], "]"}], "i"], "/.", 
                RowBox[{"ans", "[", 
                 RowBox[{"[", 
                  RowBox[{"14", ",", "j", ",", "All"}], "]"}], "]"}]}], ",", 
               "MachinePrecision"}], "]"}], ",", 
             RowBox[{"{", 
              RowBox[{"i", ",", "0", ",", "40"}], "}"}]}], "]"}]}], ";", 
          "\[IndentingNewLine]", 
          RowBox[{
           SubscriptBox["KQmodel", "j"], "=", 
           RowBox[{"Table", "[", 
            RowBox[{
             RowBox[{"SetPrecision", "[", 
              RowBox[{
               RowBox[{
                SubscriptBox[
                 RowBox[{"ToExpression", "[", 
                  RowBox[{"\"\<KQ\>\"", "<>", 
                   RowBox[{"ToString", "[", "j", "]"}]}], "]"}], "i"], "/.", 
                RowBox[{"ans", "[", 
                 RowBox[{"[", 
                  RowBox[{"15", ",", "j", ",", "All"}], "]"}], "]"}]}], ",", 
               "MachinePrecision"}], "]"}], ",", 
             RowBox[{"{", 
              RowBox[{"i", ",", "0", ",", "40"}], "}"}]}], "]"}]}], ";"}]}], 
        "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", 
       "\[IndentingNewLine]", 
       RowBox[{"quantsols", "=", 
        RowBox[{"Join", "[", 
         RowBox[{
          RowBox[{"Table", "[", 
           RowBox[{
            SubscriptBox["NQmodel", "j"], ",", 
            RowBox[{"{", 
             RowBox[{"j", ",", "1", ",", "percentilesparm"}], "}"}]}], "]"}], 
          ",", 
          RowBox[{"Table", "[", 
           RowBox[{
            SubscriptBox["KQmodel", "j"], ",", 
            RowBox[{"{", 
             RowBox[{"j", ",", "1", ",", "percentilesparm"}], "}"}]}], 
           "]"}]}], "]"}]}], ";", "\[IndentingNewLine]", 
       "\[IndentingNewLine]", 
       RowBox[{"(*", 
        RowBox[{
        "Population", " ", "Distributions", " ", "in", " ", "Given", " ", 
         "Years"}], "*)"}], "\[IndentingNewLine]", 
       RowBox[{"bataparm", "=", 
        RowBox[{"initialDistribution", "[", 
         RowBox[{"[", 
          RowBox[{"All", ",", "1"}], "]"}], "]"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"Piefunc", "[", "t_", "]"}], ":=", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"t", "\[LessEqual]", 
           RowBox[{
            RowBox[{"Length", "[", 
             RowBox[{"Pie", "/.", "inputData"}], "]"}], "-", "2"}]}], ",", 
          RowBox[{
           RowBox[{"(", 
            RowBox[{"Pie", "/.", "inputData"}], ")"}], "[", 
           RowBox[{"[", 
            RowBox[{"t", "+", "2"}], "]"}], "]"}], ",", 
          RowBox[{"Piess", "/.", "inputData"}]}], "]"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"en", "=", 
        RowBox[{"nTypes", "/.", "inputData"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{"omega", "=", 
        RowBox[{"\[Omega]", "/.", "inputData"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{"alpha", "=", 
        RowBox[{"\[Alpha]", "/.", "allParms"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{"iyear", "=", 
        RowBox[{"(", 
         RowBox[{"inityear", "/.", "allParms"}], ")"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"s0", "[", "j_", "]"}], ":=", 
        RowBox[{
         RowBox[{"s0", "[", "j", "]"}], "=", 
         RowBox[{
          RowBox[{"initialDistribution", "[", 
           RowBox[{"[", 
            RowBox[{"All", ",", "2"}], "]"}], "]"}], "[", 
          RowBox[{"[", "j", "]"}], "]"}]}]}], ";", "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"b", "[", "j_", "]"}], ":=", 
        RowBox[{
         RowBox[{"b", "[", "j", "]"}], "=", 
         RowBox[{"bataparm", "[", 
          RowBox[{"[", "j", "]"}], "]"}]}]}], ";", "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"help", "[", "t_", "]"}], ":=", 
        RowBox[{
         RowBox[{"help", "[", "t", "]"}], "=", 
         RowBox[{
          UnderoverscriptBox["\[Sum]", 
           RowBox[{"j", "=", "1"}], "en"], 
          RowBox[{
           RowBox[{"s0", "[", "j", "]"}], " ", 
           SuperscriptBox[
            RowBox[{"b", "[", "j", "]"}], "t"], "*", 
           FractionBox[
            RowBox[{" ", 
             RowBox[{"(", 
              RowBox[{"1", "-", "alpha", "-", 
               RowBox[{
                RowBox[{"(", 
                 RowBox[{"omega", "+", 
                  RowBox[{
                   RowBox[{"(", 
                    RowBox[{"1", "-", "omega"}], ")"}], " ", 
                   RowBox[{"Piefunc", "[", "t", "]"}]}]}], ")"}], " ", 
                RowBox[{"b", "[", "j", "]"}]}]}], ")"}]}], 
            RowBox[{"(", 
             RowBox[{"1", "-", "alpha", "-", 
              RowBox[{
               RowBox[{"(", 
                RowBox[{"omega", "+", 
                 RowBox[{
                  RowBox[{"(", 
                   RowBox[{"1", "-", "omega"}], ")"}], " ", 
                  RowBox[{"Piefunc", "[", "0", "]"}]}]}], ")"}], " ", 
               RowBox[{"b", "[", "j", "]"}]}]}], ")"}]]}]}]}]}], ";", " ", 
       "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"s", "[", 
         RowBox[{"i_", ",", "t_"}], "]"}], ":=", 
        FractionBox[
         RowBox[{
          RowBox[{"s0", "[", "i", "]"}], " ", 
          SuperscriptBox[
           RowBox[{"b", "[", "i", "]"}], "t"], "*", 
          FractionBox[
           RowBox[{" ", 
            RowBox[{"(", 
             RowBox[{"1", "-", "alpha", "-", 
              RowBox[{
               RowBox[{"(", 
                RowBox[{"omega", "+", 
                 RowBox[{
                  RowBox[{"(", 
                   RowBox[{"1", "-", "omega"}], ")"}], " ", 
                  RowBox[{"Piefunc", "[", "t", "]"}]}]}], ")"}], " ", 
               RowBox[{"b", "[", "i", "]"}]}]}], ")"}]}], 
           RowBox[{"(", 
            RowBox[{"1", "-", "alpha", "-", 
             RowBox[{
              RowBox[{"(", 
               RowBox[{"omega", "+", 
                RowBox[{
                 RowBox[{"(", 
                  RowBox[{"1", "-", "omega"}], ")"}], " ", 
                 RowBox[{"Piefunc", "[", "0", "]"}]}]}], ")"}], " ", 
              RowBox[{"b", "[", "i", "]"}]}]}], ")"}]]}], 
         RowBox[{"help", "[", "t", "]"}]]}], ";", "\[IndentingNewLine]", 
       "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{"(*", 
        RowBox[{
         RowBox[{
         "notice", " ", "that", " ", "we", "  ", "sample", " ", "every", " ", 
          "24", " ", "beta", " ", "generations"}], " ", "-", " ", 
         RowBox[{
         "because", " ", "otherwise", " ", "the", " ", "CSV", " ", "file", 
          " ", "is", " ", "too", " ", "large", " ", "for", " ", "tikz", " ", 
          "to", " ", "work"}]}], "*)"}], "\[IndentingNewLine]", 
       RowBox[{"betas", "=", 
        RowBox[{"Join", "[", 
         RowBox[{
          RowBox[{"{", "\"\<betai\>\"", "}"}], ",", 
          RowBox[{"Table", "[", 
           RowBox[{
            RowBox[{"SetPrecision", "[", 
             RowBox[{
              RowBox[{"bataparm", "[", 
               RowBox[{"[", "i", "]"}], "]"}], ",", "MachinePrecision"}], 
             "]"}], ",", 
            RowBox[{"{", 
             RowBox[{"i", ",", "1", ",", "en", ",", "24"}], "}"}]}], "]"}]}], 
         "]"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{"dist", "=", 
        RowBox[{"{", "}"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{"numbers", "=", 
        FractionBox[
         RowBox[{
          RowBox[{"{", 
           RowBox[{
           "1300", ",", "1900", ",", "2500", ",", "3100", ",", "3700", ",", 
            "4300", ",", "4900", ",", "5500", ",", "6100"}], "}"}], "-", 
          "1300"}], "25"]}], ";", 
       RowBox[{"(*", 
        RowBox[{
        "Which", " ", "years", " ", "the", " ", "distribution", " ", "is", 
         " ", "to", " ", "be", " ", "shown", " ", "for"}], "*)"}], 
       "\[IndentingNewLine]", 
       RowBox[{"For", "[", 
        RowBox[{
         RowBox[{"j", "=", "1"}], ",", 
         RowBox[{"j", "<=", 
          RowBox[{"Length", "[", "numbers", "]"}]}], ",", 
         RowBox[{"j", "++"}], ",", 
         RowBox[{
          RowBox[{"i", "=", 
           RowBox[{"numbers", "[", 
            RowBox[{"[", "j", "]"}], "]"}]}], ";", "\[IndentingNewLine]", 
          RowBox[{"t", "=", 
           RowBox[{"numbers", "[", 
            RowBox[{"[", "j", "]"}], "]"}]}], ";", "\[IndentingNewLine]", 
          RowBox[{"Quiet", "[", 
           RowBox[{"dist", "=", 
            RowBox[{"Append", "[", 
             RowBox[{"dist", ",", 
              RowBox[{"Join", "[", 
               RowBox[{
                RowBox[{"{", 
                 RowBox[{"\"\<dist\>\"", "<>", 
                  RowBox[{"ToString", "[", 
                   RowBox[{
                    RowBox[{"t", "*", "25"}], "+", 
                    RowBox[{"(", 
                    RowBox[{"inityear", "/.", "inputData"}], ")"}]}], "]"}]}],
                  "}"}], ",", 
                RowBox[{"Table", "[", 
                 RowBox[{
                  RowBox[{"SetPrecision", "[", 
                   RowBox[{
                    RowBox[{"s", "[", 
                    RowBox[{"i", ",", "t"}], "]"}], ",", "MachinePrecision"}],
                    "]"}], ",", 
                  RowBox[{"{", 
                   RowBox[{"i", ",", "1", ",", "en", ",", "24"}], "}"}]}], 
                 "]"}]}], "]"}]}], "]"}]}], "]"}], ";"}]}], 
        "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", 
       RowBox[{"Quiet", "[", 
        RowBox[{"dist", "=", 
         RowBox[{"Append", "[", 
          RowBox[{"dist", ",", 
           RowBox[{"Join", "[", 
            RowBox[{
             RowBox[{"{", 
              RowBox[{"\"\<dist\>\"", "<>", 
               RowBox[{"ToString", "[", 
                RowBox[{
                 RowBox[{"28", "*", "25"}], "+", 
                 RowBox[{"(", 
                  RowBox[{"inityear", "/.", "inputData"}], ")"}]}], "]"}]}], 
              "}"}], ",", 
             RowBox[{"Table", "[", 
              RowBox[{
               RowBox[{"SetPrecision", "[", 
                RowBox[{
                 RowBox[{"s", "[", 
                  RowBox[{"i", ",", "28"}], "]"}], ",", "MachinePrecision"}], 
                "]"}], ",", 
               RowBox[{"{", 
                RowBox[{"i", ",", "1", ",", "en", ",", "24"}], "}"}]}], 
              "]"}]}], "]"}]}], "]"}]}], "]"}], ";", "\[IndentingNewLine]", 
       "\[IndentingNewLine]", 
       RowBox[{"destination", "=", 
        RowBox[{
        "path", "<>", "\"\</Outputs/Model/\>\"", "<>", "foldername", "<>", 
         "\"\</patienceDistributionOverTime.csv\>\""}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"Export", "[", 
        RowBox[{"destination", ",", 
         RowBox[{"columnAttach", "[", 
          RowBox[{"betas", ",", 
           RowBox[{"Transpose", "[", "dist", "]"}]}], "]"}], ",", 
         "\"\<Table\>\"", ",", 
         RowBox[{"\"\<FieldSeparators\>\"", "->", "\"\<,\>\""}]}], "]"}], ";",
        "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{"(*", 
        RowBox[{"Cutoffs", " ", "For", " ", "Percentiles"}], "*)"}], 
       "\[IndentingNewLine]", 
       RowBox[{"qbounds", "=", 
        RowBox[{"Join", "[", 
         RowBox[{
          RowBox[{"{", "0", "}"}], ",", 
          RowBox[{"Quantile", "[", 
           RowBox[{
            RowBox[{"Table", "[", 
             RowBox[{"i", ",", 
              RowBox[{"{", 
               RowBox[{"i", ",", "1", ",", "en"}], "}"}]}], "]"}], ",", 
            RowBox[{"Table", "[", 
             RowBox[{
              FractionBox["i", "percentilesparm"], ",", 
              RowBox[{"{", 
               RowBox[{"i", ",", "1", ",", "percentilesparm"}], "}"}]}], 
             "]"}]}], "]"}]}], "]"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{"names", "=", 
        RowBox[{"{", 
         RowBox[{
         "\"\<lindex\>\"", ",", "\"\<uIndex\>\"", ",", "\"\<lbeta\>\"", ",", 
          "\"\<ubeta\>\""}], "}"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{"destination", "=", 
        RowBox[{
        "path", "<>", "\"\</Outputs/Model/\>\"", "<>", "foldername", "<>", 
         "\"\</ModelPercentileBoundaries.csv\>\""}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"Export", "[", 
        RowBox[{"destination", ",", 
         RowBox[{"Insert", "[", 
          RowBox[{
           RowBox[{"Table", "[", 
            RowBox[{
             RowBox[{"{", 
              RowBox[{
               RowBox[{
                RowBox[{"qbounds", "[", 
                 RowBox[{"[", "i", "]"}], "]"}], "+", "1"}], ",", 
               RowBox[{"qbounds", "[", 
                RowBox[{"[", 
                 RowBox[{"i", "+", "1"}], "]"}], "]"}], ",", 
               RowBox[{"N", "[", 
                RowBox[{
                 RowBox[{"Round", "[", 
                  RowBox[{
                   RowBox[{
                    RowBox[{"bataparm", "[", 
                    RowBox[{"[", 
                    RowBox[{
                    RowBox[{"qbounds", "[", 
                    RowBox[{"[", "i", "]"}], "]"}], "+", "1"}], "]"}], "]"}], 
                    "*", "100"}], ",", "1"}], "]"}], "/", "100"}], "]"}], ",", 
               RowBox[{"Round", "[", 
                RowBox[{
                 RowBox[{"bataparm", "[", 
                  RowBox[{"[", 
                   RowBox[{"qbounds", "[", 
                    RowBox[{"[", 
                    RowBox[{"i", "+", "1"}], "]"}], "]"}], "]"}], "]"}], ",", 
                 "0.01"}], "]"}]}], "}"}], ",", 
             RowBox[{"{", 
              RowBox[{"i", ",", "1", ",", 
               RowBox[{
                RowBox[{"Length", "[", "qbounds", "]"}], "-", "1"}]}], 
              "}"}]}], "]"}], ",", "names", ",", "1"}], "]"}]}], "]"}], ";", 
       "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{"socbeta", "=", 
        RowBox[{"Table", "[", 
         RowBox[{
          RowBox[{"Sum", "[", 
           RowBox[{
            RowBox[{
             RowBox[{"s", "[", 
              RowBox[{"i", ",", "t"}], "]"}], "*", 
             RowBox[{"b", "[", "i", "]"}]}], ",", 
            RowBox[{"{", 
             RowBox[{"i", ",", "1", ",", "en"}], "}"}]}], "]"}], ",", 
          RowBox[{"{", 
           RowBox[{"t", ",", "0", ",", "40"}], "}"}]}], "]"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"namesq", "=", 
        RowBox[{"Join", "[", 
         RowBox[{
          RowBox[{"Table", "[", 
           RowBox[{
            RowBox[{"\"\<nq\>\"", "<>", 
             RowBox[{"ToString", "[", "j", "]"}], "<>", "\"\<model\>\""}], 
            ",", 
            RowBox[{"{", 
             RowBox[{"j", ",", "1", ",", "percentilesparm"}], "}"}]}], "]"}], 
          ",", 
          RowBox[{"Table", "[", 
           RowBox[{
            RowBox[{"\"\<kq\>\"", "<>", 
             RowBox[{"ToString", "[", "j", "]"}], "<>", "\"\<model\>\""}], 
            ",", 
            RowBox[{"{", 
             RowBox[{"j", ",", "1", ",", "percentilesparm"}], "}"}]}], 
           "]"}]}], "]"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{"names", "=", 
        RowBox[{"Join", "[", 
         RowBox[{
          RowBox[{"{", "\"\<year\>\"", "}"}], ",", "namesq"}], "]"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"names", "=", 
        RowBox[{"Join", "[", 
         RowBox[{"names", ",", 
          RowBox[{"{", "\"\<socbetamodel\>\"", "}"}]}], "]"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"year", "=", 
        RowBox[{"Table", "[", 
         RowBox[{
          RowBox[{
           RowBox[{"i", "*", "25"}], "+", "iyear"}], ",", 
          RowBox[{"{", 
           RowBox[{"i", ",", "0", ",", "40"}], "}"}]}], "]"}]}], ";", 
       "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{"destination", "=", 
        RowBox[{
        "path", "<>", "\"\</Outputs/Model/\>\"", "<>", "foldername", "<>", 
         "\"\</PatiencePopCapitalShares.csv\>\""}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"Export", "[", 
        RowBox[{"destination", ",", 
         RowBox[{"Insert", "[", 
          RowBox[{
           RowBox[{"columnAttach", "[", 
            RowBox[{"year", ",", 
             RowBox[{"Transpose", "[", "quantsols", "]"}], ",", "socbeta"}], 
            "]"}], ",", "names", ",", "1"}], "]"}], ",", "\"\<Table\>\"", ",", 
         RowBox[{"\"\<FieldSeparators\>\"", "->", "\"\<,\>\""}]}], "]"}], 
       ";"}]}], "\[IndentingNewLine]", "\[IndentingNewLine]", "]"}]}], ";"}], 
  "\[IndentingNewLine]"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.},
 CellChangeTimes->{{3.902819804224226*^9, 3.902819832071514*^9}, {
   3.90281986605177*^9, 3.902819890145318*^9}, {3.902819924555356*^9, 
   3.902819956645175*^9}, {3.902819991797668*^9, 3.902820069664415*^9}, {
   3.902820106400585*^9, 3.90282010653379*^9}, {3.902820671028026*^9, 
   3.902820698484721*^9}, {3.902821266558255*^9, 3.902821279615345*^9}, {
   3.902821462857946*^9, 3.902821480612269*^9}, 3.90282154919725*^9, {
   3.902824010127427*^9, 3.902824016709558*^9}, {3.902824233730113*^9, 
   3.902824236193296*^9}, 3.90298671588168*^9},
 CellLabel->"In[47]:=",ExpressionUUID->"d0e93cd0-b9a4-4575-8aac-c153cbfda9e5"]
}, Closed]],

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{"--", 
   RowBox[{"--", 
    RowBox[{"--", " ", 
     RowBox[{
      RowBox[{
       RowBox[{"Mutation", " ", "--"}], "--"}], "--"}]}]}]}], "*)"}]], "Input",
 CellChangeTimes->{{3.902827158346551*^9, 3.902827163378873*^9}},
 CellLabel->"In[48]:=",ExpressionUUID->"b2ce7e60-13ab-456e-8fc0-bc382130a1f1"],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{
   RowBox[{
    RowBox[{"SolveModelCostsGiven", " ", "-", " ", 
     RowBox[{"Expand", " ", "to", " ", 
      RowBox[{"view", ".", " ", "N"}], " ", "agents"}]}], ";", " ", 
    RowBox[{
    "Takes", " ", "child", " ", "costs", " ", "as", " ", "given", " ", "and", 
     " ", "infers", " ", "population", " ", "growth", " ", "rates"}]}], ",", 
   " ", 
   RowBox[{"k", " ", "on", " ", "saddle", " ", 
    RowBox[{"path", ".", " ", "Pie"}], " ", "Changes"}], ",", " ", 
   RowBox[{
    RowBox[{
    "omegas", " ", "can", " ", "be", " ", "anhything", " ", "between", " ", 
     "0", " ", "and", " ", 
     RowBox[{"1", " ", "--"}], " ", "if", " ", "\[Omega]"}], "=", 
    RowBox[{
     RowBox[{
     "0", " ", "then", " ", "Blanchard", " ", "type", " ", "selfishness", " ", 
      RowBox[{"mechanism", ".", " ", "For"}], " ", "Mutation"}], " ", "-", 
     " ", 
     RowBox[{
     "as", " ", "such", " ", "format", " ", "of", " ", "output", " ", "takes",
       " ", "similar", " ", "form", " ", "to", " ", "format", " ", "of", " ", 
      RowBox[{"SolverHelper2", "."}]}]}]}]}], "*)"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.},
 CellChangeTimes->{{3.5450253019140635`*^9, 3.545025304915063*^9}, {
   3.5450324742890635`*^9, 3.5450324819140635`*^9}, {3.724479346029998*^9, 
   3.7244794610184035`*^9}, {3.7244795438463507`*^9, 3.724479554254569*^9}, {
   3.7260565353620577`*^9, 3.7260565430614977`*^9}, 3.7260578532684374`*^9, 
   3.726579461512018*^9, {3.726579559728636*^9, 3.726579586301156*^9}, {
   3.7265804157025948`*^9, 3.726580472134823*^9}, {3.726675052388584*^9, 
   3.7266750541206837`*^9}, {3.726736336745963*^9, 3.72673634385637*^9}, {
   3.7267458479639735`*^9, 3.7267458612117314`*^9}, {3.7270949226440563`*^9, 
   3.7270949246821723`*^9}, 3.727096924615328*^9, 3.7271009968402452`*^9, {
   3.7271015671358647`*^9, 3.7271015677228985`*^9}, {3.7610437803591704`*^9, 
   3.7610437849279823`*^9}, {3.7619207454984493`*^9, 3.7619207476240177`*^9}, 
   3.7730639713097205`*^9, {3.776491683018301*^9, 3.7764917078746634`*^9}, {
   3.8515995582518587`*^9, 3.8515995628012094`*^9}, {3.851768684051326*^9, 
   3.8517686869411545`*^9}, {3.8520219625179977`*^9, 
   3.8520219654061565`*^9}, {3.8523736907830973`*^9, 3.852373695966022*^9}, {
   3.8945986752469788`*^9, 3.8945987151205263`*^9}, {3.899959950199046*^9, 
   3.899959967359538*^9}, {3.9000475981904078`*^9, 3.900047604999505*^9}, 
   3.900241801735772*^9, {3.9028271710513687`*^9, 3.902827192072215*^9}},
 CellLabel->"In[49]:=",ExpressionUUID->"6923173b-7cb8-430a-8c88-dde690549f80"],

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{
   RowBox[{"Expand", " ", "to", " ", 
    RowBox[{"View", ":", " ", 
     RowBox[{
     "Returns", " ", "the", " ", "error", " ", "in", " ", "the", " ", "final",
       " ", "FOC", " ", "given", " ", "the", " ", "guess", " ", "of", " ", 
      "relative", " ", "initial", " ", "consumption", " ", "in", " ", "the", 
      " ", "first", " ", 
      RowBox[{"position", ".", " ", "In"}], " ", "the", " ", "second", " ", 
      "position"}]}]}], ",", " ", 
   RowBox[{
   "returns", " ", "the", " ", "solutions", " ", "given", " ", "the", " ", 
    "guess", "  ", "of", " ", "relative", " ", "initial", " ", 
    RowBox[{"consumption", ".", "\[IndentingNewLine]", "Need"}], " ", "to", 
    " ", "Adjust", " ", "until", " ", "error", " ", "is", " ", 
    RowBox[{"zero", "."}]}]}], "*)"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.},
 CellChangeTimes->{{3.7265804668015175`*^9, 3.726580472134823*^9}, 
   3.894598675247232*^9},
 CellLabel->"In[50]:=",ExpressionUUID->"234a0161-b3f2-484a-8aa6-eb5f8cb806dc"],

Cell[BoxData[
 RowBox[{
  RowBox[{
   RowBox[{"SolveModelCostsGiven", "[", "parameterVector_", "]"}], ":=", 
   "\[IndentingNewLine]", 
   RowBox[{"Module", "[", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{
       RowBox[{"pVectorAll", "=", "parameterVector"}], ",", "pVector", ",", 
       "\[IndentingNewLine]", "\[Alpha]", ",", "\[Beta]A", ",", "\[Beta]B", 
       ",", "Pie", ",", "time", ",", "\[Xi]", ",", "\[Nu]", ",", 
       "\[IndentingNewLine]", "\[IndentingNewLine]", "wtilde", ",", "r", ",", 
       "Cetilde", ",", "citilde", ",", "gDee", ",", "eN", ",", "kiitilde", 
       ",", "Dee", ",", "afunc", ",", "ass", ",", "Deefuncx", ",", 
       "\[IndentingNewLine]", "\[IndentingNewLine]", "eqs", ",", "eqs1", ",", 
       "eqs2", ",", "eqs3", ",", "eqs4", ",", "eqs5", ",", 
       "\[IndentingNewLine]", "\[IndentingNewLine]", "eq", ",", "eq1", ",", 
       "eq2", ",", "eq3", ",", "eq4", ",", "eq5", ",", "\[IndentingNewLine]", 
       "\[IndentingNewLine]", "varRelcB0", ",", "answerAllNi", ",", 
       "answerktilde", ",", "answerAllci", ",", "answerAllKi", ",", 
       "answerAllsi", ",", "answerW", ",", "points", ",", "answerAllYi", ",", 
       "answerY", ",", "answera", ",", "relbeta", ",", "eNdata", ",", "greN", 
       ",", "answerD", ",", "answersavingsrate", ",", "answerK", ",", 
       "answery", ",", "Piess", ",", "Piefunc", ",", "relonealphabeta", ",", 
       "\[IndentingNewLine]", "\[IndentingNewLine]", "a", ",", " ", 
       "\[Delta]", ",", "N0", ",", "grDee", ",", "gNss", ",", "geN", ",", 
       "ktildess", ",", "ansSS", ",", "answerTemp", ",", "answerkitilde", ",",
        " ", "answerctilde", ",", "  ", "answerN", ",", "answerp", ",", 
       "answerR", ",", "answerCtildeAg", ",", "vars", ",", "answer", ",", " ",
        "\[Beta]vec", ",", "propNvec", ",", "sorted\[Beta]Location", ",", 
       "nTypes", ",", " ", "acc", ",", "temp", ",", "temp2", ",", "temp3", 
       ",", "tempNp", ",", "helper", ",", "helper2", ",", "helper3", ",", 
       "ci", ",", "Kii", ",", "Nii", ",", "sii", ",", "cij", ",", "Kij", ",", 
       "Nij", ",", "pct", ",", "answerCQuantiles", ",", "answerKQuantiles", 
       ",", "answerNQuantiles", ",", "indexpct", ",", "answerKii", ",", 
       "answerKi", ",", "answerSharesSelectedYears", ",", 
       "answerSocietalBeta", ",", "inityear", ",", "currentyear", ",", 
       "cyperiod", ",", "initPoint", ",", "\[Omega]", ",", "answerFert", ",", 
       "rN", ",", "CetildeN", ",", "wtildeN", ",", "afuncN", ",", "wap", ",", 
       "helpersums", ",", "kitildeN", ",", "citildex", ",", "ansDif", ",", 
       "answergN", ",", "aData"}], "}"}], ",", "\[IndentingNewLine]", 
     "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"pVector", "=", 
       RowBox[{"pVectorAll", "[", 
        RowBox[{"[", 
         RowBox[{"All", ",", "2"}], "]"}], "]"}]}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{"inityear", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "1", "]"}], "]"}]}], ";", "\[IndentingNewLine]", 
      RowBox[{"currentyear", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "2", "]"}], "]"}]}], ";", "\[IndentingNewLine]", 
      RowBox[{"cyperiod", "=", 
       FractionBox[
        RowBox[{"currentyear", "-", "inityear"}], "25"]}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{"\[Delta]", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "3", "]"}], "]"}]}], ";", "     ", 
      RowBox[{"(*", 
       RowBox[{"Total", " ", 
        RowBox[{"Land", "/", "Capital"}]}], "*)"}], "\[IndentingNewLine]", 
      RowBox[{"aData", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "4", "]"}], "]"}]}], ";", "\[IndentingNewLine]", 
      RowBox[{"greN", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "5", "]"}], "]"}]}], ";", "\[IndentingNewLine]", 
      RowBox[{"N0", "=", "0.2811310074309351`"}], ";", "\[IndentingNewLine]", 
      RowBox[{"Dee", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "6", "]"}], "]"}]}], ";", "  ", 
      RowBox[{"(*", 
       RowBox[{"Level", " ", "of", " ", "TFP"}], "*)"}], 
      "\[IndentingNewLine]", 
      RowBox[{"grDee", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "7", "]"}], "]"}]}], ";", "\[IndentingNewLine]", 
      RowBox[{"\[Nu]", " ", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "8", "]"}], "]"}]}], ";", "   ", 
      RowBox[{"(*", 
       RowBox[{
        RowBox[{"Land", "/", "Capital"}], " ", "Share", " ", "in", " ", 
        "Production", " ", "Function"}], "*)"}], "\[IndentingNewLine]", 
      RowBox[{"\[Alpha]", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "9", "]"}], "]"}]}], ";", "     ", 
      RowBox[{"(*", 
       RowBox[{"Preference", " ", "weight", " ", "on", " ", "consumption"}], 
       "*)"}], "\[IndentingNewLine]", 
      RowBox[{"Pie", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "10", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", 
       RowBox[{
       "Probability", " ", "of", " ", "death", " ", "of", " ", "adults"}], 
       "*)"}], "\[IndentingNewLine]", 
      RowBox[{"Piess", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "11", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", 
       RowBox[{
       "Probability", " ", "of", " ", "death", " ", "of", " ", "adults"}], 
       "*)"}], "\[IndentingNewLine]", 
      RowBox[{"\[Omega]", " ", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "12", "]"}], "]"}]}], ";", "    ", 
      RowBox[{"(*", 
       RowBox[{
        RowBox[{"Penalty", " ", "for", " ", "holding", " ", "negative", " ", 
         RowBox[{"capital", ".", " ", "Set"}], " ", "\[Xi]"}], "=", 
        RowBox[{
         RowBox[{"0", " ", "if", " ", 
          RowBox[{"unconstrained", ".", " ", "Set"}], " ", "\[Xi]"}], "=", 
         RowBox[{"\[Infinity]", " ", "if", " ", "constrained"}]}]}], "*)"}], 
      "\[IndentingNewLine]", 
      RowBox[{"time", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "13", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", " ", 
       RowBox[{"The", " ", "time", " ", 
        RowBox[{"periods", "/", "generations"}], " ", "under", " ", 
        RowBox[{"consideration", "."}]}], "*)"}], "\[IndentingNewLine]", 
      RowBox[{"\[Beta]vec", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "14", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", 
       RowBox[{"Reads", " ", "in", " ", "the", " ", "betas"}], "*)"}], 
      "\[IndentingNewLine]", 
      RowBox[{"propNvec", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "15", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", 
       RowBox[{"Reads", " ", "in", " ", "the", " ", "betas"}], "*)"}], 
      "\[IndentingNewLine]", 
      RowBox[{
       SubscriptBox["ktilde", 
        RowBox[{"-", "1"}]], "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "16", "]"}], "]"}]}], ";", "\[IndentingNewLine]", 
      RowBox[{"acc", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "17", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", 
       RowBox[{"Accuracy", "/", "precision"}], "*)"}], "\[IndentingNewLine]", 
      RowBox[{"pct", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "18", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", 
       RowBox[{"Number", " ", "of", " ", "percentiles"}], "*)"}], 
      "\[IndentingNewLine]", 
      RowBox[{"If", "[", 
       RowBox[{
        RowBox[{
         RowBox[{"Length", "[", "pVector", "]"}], "\[Equal]", "19"}], ",", 
        "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"initPoint", "=", 
          RowBox[{"pVector", "[", 
           RowBox[{"[", "19", "]"}], "]"}]}], ";"}]}], "]"}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"Piefunc", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"Piefunc", "[", "t", "]"}], "=", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"t", "\[LessEqual]", 
           RowBox[{
            RowBox[{"Length", "[", "Pie", "]"}], "-", "2"}]}], ",", 
          RowBox[{"Pie", "[", 
           RowBox[{"[", 
            RowBox[{"t", "+", "2"}], "]"}], "]"}], ",", "Piess"}], "]"}]}]}], 
      ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"sorted\[Beta]Location", "=", 
       RowBox[{"Reverse", "[", 
        RowBox[{"Ordering", "[", "\[Beta]vec", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", 
       RowBox[{
       "Returns", " ", "the", " ", "location", " ", "of", " ", "the", " ", 
        "sorted", " ", "betas", " ", "from", " ", "largest", " ", "to", " ", 
        "smallest", " ", "in", " ", "pVector\[Beta]"}], "*)"}], 
      "\[IndentingNewLine]", 
      RowBox[{"nTypes", "=", 
       RowBox[{"Length", "[", "\[Beta]vec", "]"}]}], ";", "  ", 
      RowBox[{"(*", 
       RowBox[{"Number", " ", "of", " ", "different", " ", "types"}], "*)"}], 
      "\[IndentingNewLine]", 
      RowBox[{"For", "[", 
       RowBox[{
        RowBox[{"i", "=", "1"}], ",", 
        RowBox[{"i", "\[LessEqual]", "nTypes"}], ",", 
        RowBox[{"i", "++"}], ",", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"j", "=", 
          RowBox[{"sorted\[Beta]Location", "[", 
           RowBox[{"[", "i", "]"}], "]"}]}], ";", 
         RowBox[{"(*", 
          RowBox[{
          "Find", " ", "the", " ", "location", " ", "of", " ", "the", " ", 
           "sorted", " ", "beta"}], "*)"}], "\[IndentingNewLine]", 
         RowBox[{
          SubscriptBox["\[Beta]", "i"], "=", 
          RowBox[{"\[Beta]vec", "[", 
           RowBox[{"[", "j", "]"}], "]"}]}], ";", " ", 
         RowBox[{"(*", 
          RowBox[{
          "Assigns", " ", "beta", " ", "in", " ", "the", " ", "right", " ", 
           "order"}], "*)"}], "\[IndentingNewLine]", 
         RowBox[{
          SubscriptBox["propN", "i"], "=", 
          RowBox[{"SetPrecision", "[", 
           RowBox[{
            RowBox[{"propNvec", "[", 
             RowBox[{"[", "j", "]"}], "]"}], ",", "acc"}], "]"}]}], ";", " ", 
         RowBox[{"(*", 
          RowBox[{
          "Assigns", " ", "beta", " ", "in", " ", "the", " ", "right", " ", 
           "order"}], "*)"}], "\[IndentingNewLine]", 
         RowBox[{
          SubscriptBox["relN0", "i"], "=", 
          RowBox[{"SetPrecision", "[", 
           RowBox[{
            FractionBox[
             SubscriptBox["propN", "i"], 
             SubscriptBox["propN", "1"]], ",", "acc"}], "]"}]}], ";", " ", 
         RowBox[{"(*", 
          RowBox[{
          "Calculate", " ", "the", " ", "proportions", " ", "of", " ", 
           "people", " ", "in", " ", "each", " ", "type", " ", "relative", 
           " ", "to", " ", "the", " ", "highest", " ", "beta", " ", "type"}], 
          "*)"}], "\[IndentingNewLine]", 
         RowBox[{
          SubscriptBox["relctilde0", "i"], "=", 
          RowBox[{"SetPrecision", "[", 
           RowBox[{
            RowBox[{
             FractionBox[
              RowBox[{"SetPrecision", "[", 
               RowBox[{
                RowBox[{
                 SubscriptBox["\[Beta]", "i"], "*", " ", 
                 RowBox[{"(", 
                  RowBox[{"1", "-", "\[Alpha]", "-", 
                   RowBox[{
                    SubscriptBox["\[Beta]", "1"], "*", 
                    RowBox[{"(", 
                    RowBox[{"\[Omega]", "+", 
                    RowBox[{
                    RowBox[{"(", 
                    RowBox[{"1", "-", "\[Omega]"}], ")"}], " ", 
                    RowBox[{"Piefunc", "[", "0", "]"}]}]}], ")"}]}]}], 
                  ")"}]}], ",", "acc"}], "]"}], 
              RowBox[{"SetPrecision", "[", 
               RowBox[{
                RowBox[{
                 SubscriptBox["\[Beta]", "1"], " ", "*", 
                 RowBox[{"(", 
                  RowBox[{"1", "-", "\[Alpha]", "-", 
                   RowBox[{
                    SubscriptBox["\[Beta]", "i"], "*", 
                    RowBox[{"(", 
                    RowBox[{"\[Omega]", "+", 
                    RowBox[{
                    RowBox[{"(", 
                    RowBox[{"1", "-", "\[Omega]"}], ")"}], " ", 
                    RowBox[{"Piefunc", "[", "0", "]"}]}]}], ")"}]}]}], 
                  ")"}]}], ",", "acc"}], "]"}]], "*", 
             RowBox[{"SetPrecision", "[", 
              RowBox[{
               SubscriptBox["relN0", "i"], ",", "acc"}], "]"}]}], ",", 
            "acc"}], "]"}]}], ";"}]}], "  ", 
       RowBox[{"(*", " ", 
        RowBox[{
        "Given", " ", "the", " ", "above", " ", "calculate", " ", "the", " ", 
         "relative", " ", "proportions", " ", "of", " ", "consumption", " ", 
         "of", " ", "each", " ", "type", " ", "relative", " ", "to", " ", 
         "the", " ", "highest", " ", "beta", " ", "type"}], "*)"}], 
       "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
       "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"(*", 
       RowBox[{
        RowBox[{
         RowBox[{"afunc", "[", "t_", "]"}], ":=", 
         RowBox[{"a", "[", 
          RowBox[{"[", 
           RowBox[{"Length", "[", "a", "]"}], "]"}], "]"}]}], ";"}], "*)"}], 
      "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"gDee", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"gDee", "[", "t", "]"}], "=", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"t", "\[LessEqual]", 
           RowBox[{
            RowBox[{"Length", "[", "Dee", "]"}], "-", "2"}]}], ",", 
          FractionBox[
           RowBox[{"Dee", "[", 
            RowBox[{"[", 
             RowBox[{"t", "+", "2"}], "]"}], "]"}], 
           RowBox[{"Dee", "[", 
            RowBox[{"[", 
             RowBox[{"t", "+", "1"}], "]"}], "]"}]], ",", "grDee"}], 
         "]"}]}]}], ";", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"Deefuncx", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"Deefuncx", "[", "t", "]"}], "=", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"t", "\[Equal]", 
           RowBox[{"-", "1"}]}], ",", "1", ",", 
          RowBox[{
           RowBox[{"Deefuncx", "[", 
            RowBox[{"t", "-", "1"}], "]"}], "*", 
           RowBox[{"gDee", "[", "t", "]"}]}]}], "]"}]}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"Clear", "[", 
       RowBox[{"gNss", ",", "ktildess", ",", "ass"}], "]"}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{"gNss", "=", "greN"}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"ansSS", "=", 
       RowBox[{"FindRoot", "[", 
        RowBox[{
         RowBox[{"{", 
          RowBox[{
           RowBox[{"gNss", "==", 
            RowBox[{
             RowBox[{"(", 
              RowBox[{
               RowBox[{
                RowBox[{"-", "ass"}], " ", "Piess", " ", 
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{"-", "1"}], "+", "\[Alpha]"}], ")"}], " ", 
                RowBox[{"(", 
                 RowBox[{"1", "+", 
                  RowBox[{"Piess", " ", 
                   SubscriptBox["\[Beta]", "1"], " ", 
                   RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "\[Omega]"}], ")"}]}], "-", 
                  RowBox[{
                   SubscriptBox["\[Beta]", "1"], " ", "\[Omega]"}]}], ")"}]}],
                "+", 
               RowBox[{"ktildess", " ", 
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{"-", "1"}], "+", "\[Delta]"}], ")"}], " ", 
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{"-", "1"}], "+", "\[Alpha]", "+", 
                  RowBox[{
                   SubscriptBox["\[Beta]", "1"], " ", 
                   RowBox[{"(", 
                    RowBox[{"Piess", "+", "\[Omega]", "-", 
                    RowBox[{"Piess", " ", "\[Omega]"}]}], ")"}]}]}], ")"}]}], 
               "+", 
               RowBox[{
                SuperscriptBox["ktildess", "\[Nu]"], " ", 
                RowBox[{"(", 
                 RowBox[{"1", "-", 
                  RowBox[{"Piess", " ", 
                   SubscriptBox["\[Beta]", "1"]}], "+", 
                  RowBox[{
                   RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "Piess"}], ")"}], " ", 
                   SubscriptBox["\[Beta]", "1"], " ", "\[Omega]"}], "+", 
                  RowBox[{"\[Alpha]", " ", 
                   RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", 
                    RowBox[{
                    SubscriptBox["\[Beta]", "1"], " ", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "\[Nu]"}], ")"}], " ", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "Piess"}], "+", 
                    RowBox[{
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "Piess"}], ")"}], " ", 
                    "\[Omega]"}]}], ")"}]}]}], ")"}]}]}], ")"}]}]}], ")"}], 
             "/", 
             RowBox[{"(", 
              RowBox[{"ass", "+", 
               RowBox[{"ass", " ", "Piess", " ", 
                SubscriptBox["\[Beta]", "1"], " ", 
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{"-", "1"}], "+", "\[Omega]"}], ")"}]}], "-", 
               RowBox[{"ass", " ", 
                SubscriptBox["\[Beta]", "1"], " ", "\[Omega]"}], "-", 
               RowBox[{
                SuperscriptBox["grDee", 
                 FractionBox["1", 
                  RowBox[{"1", "-", "\[Nu]"}]]], " ", "ktildess", " ", 
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{"-", "1"}], "+", "\[Alpha]", "+", 
                  RowBox[{
                   SubscriptBox["\[Beta]", "1"], " ", 
                   RowBox[{"(", 
                    RowBox[{"Piess", "+", "\[Omega]", "-", 
                    RowBox[{"Piess", " ", "\[Omega]"}]}], ")"}]}]}], 
                 ")"}]}]}], ")"}]}]}], ",", 
           RowBox[{"ktildess", "==", 
            SuperscriptBox[
             RowBox[{"(", 
              FractionBox[
               RowBox[{
                RowBox[{
                 SuperscriptBox["grDee", 
                  FractionBox["1", 
                   RowBox[{"1", "-", "\[Nu]"}]]], " ", "gNss"}], "+", 
                RowBox[{
                 RowBox[{"(", 
                  RowBox[{
                   RowBox[{"Piess", " ", 
                    RowBox[{"(", 
                    RowBox[{"1", "-", "\[Omega]"}], ")"}]}], "+", 
                   "\[Omega]"}], ")"}], " ", 
                 SubscriptBox["\[Beta]", "1"], " ", 
                 RowBox[{"(", 
                  RowBox[{
                   RowBox[{"-", "1"}], "+", "\[Delta]"}], ")"}]}]}], 
               RowBox[{
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{"Piess", " ", 
                   RowBox[{"(", 
                    RowBox[{"1", "-", "\[Omega]"}], ")"}]}], "+", 
                  "\[Omega]"}], ")"}], " ", 
                SubscriptBox["\[Beta]", "1"], " ", "\[Nu]"}]], ")"}], 
             FractionBox["1", 
              RowBox[{
               RowBox[{"-", "1"}], "+", "\[Nu]"}]]]}]}], "}"}], ",", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"{", 
            RowBox[{"ass", ",", "0.15"}], "}"}], ",", 
           RowBox[{"{", 
            RowBox[{"ktildess", ",", "0.06"}], "}"}]}], "}"}]}], "]"}]}], ";",
       "\[IndentingNewLine]", 
      RowBox[{"(*", 
       RowBox[{
        RowBox[{"gNss", "=", 
         RowBox[{"gNss", "/.", "ansSS"}]}], ";"}], "*)"}], 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"ass", "=", 
       RowBox[{"ass", "/.", "ansSS"}]}], ";", "\[IndentingNewLine]", 
      RowBox[{
       SubscriptBox["ax", "time"], "=", "ass"}], ";", "\[IndentingNewLine]", 
      RowBox[{
       SubscriptBox["ax", 
        RowBox[{"time", "+", "1"}]], "=", "ass"}], ";", "\[IndentingNewLine]",
       "\[IndentingNewLine]", 
      RowBox[{"ktildess", "=", 
       RowBox[{"ktildess", "/.", "ansSS"}]}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"afunc", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"afunc", "[", "t", "]"}], "=", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"t", "\[LessEqual]", 
           RowBox[{
            RowBox[{"Length", "[", "aData", "]"}], "-", "2"}]}], ",", 
          RowBox[{"aData", "[", 
           RowBox[{"[", 
            RowBox[{"t", "+", "2"}], "]"}], "]"}], ",", "ass"}], "]"}]}]}], 
      ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"wtilde", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"wtilde", "[", "t", "]"}], "=", 
        RowBox[{
         RowBox[{"(", 
          RowBox[{"1", "-", "\[Nu]"}], ")"}], "*", 
         SuperscriptBox[
          RowBox[{"(", 
           RowBox[{"SetPrecision", "[", 
            RowBox[{
             SubscriptBox["ktilde", "t"], ",", "acc"}], "]"}], ")"}], 
          RowBox[{"SetPrecision", "[", 
           RowBox[{"\[Nu]", ",", "acc"}], "]"}]]}]}]}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"r", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"r", "[", "t", "]"}], "=", 
        RowBox[{"\[Nu]", "*", 
         SuperscriptBox[
          RowBox[{"(", 
           RowBox[{"SetPrecision", "[", 
            RowBox[{
             SubscriptBox["ktilde", "t"], ",", "acc"}], "]"}], ")"}], 
          RowBox[{"SetPrecision", "[", 
           RowBox[{
            RowBox[{"\[Nu]", "-", "1"}], ",", "acc"}], "]"}]]}]}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"Cetilde", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"Cetilde", "[", "t", "]"}], "=", 
        RowBox[{
         SuperscriptBox[
          RowBox[{"SetPrecision", "[", 
           RowBox[{
            SubscriptBox["ktilde", "t"], ",", "acc"}], "]"}], 
          RowBox[{"SetPrecision", "[", 
           RowBox[{"\[Nu]", ",", "acc"}], "]"}]], "-", 
         RowBox[{"(", 
          RowBox[{
           RowBox[{
            RowBox[{"SetPrecision", "[", 
             RowBox[{
              SubscriptBox["gN", 
               RowBox[{"1", "+", "t"}]], ",", "acc"}], "]"}], " ", 
            SuperscriptBox[
             RowBox[{"gDee", "[", 
              RowBox[{"1", "+", "t"}], "]"}], 
             FractionBox["1", 
              RowBox[{"1", "-", "\[Nu]"}]]], " ", 
            RowBox[{"SetPrecision", "[", 
             RowBox[{
              SubscriptBox["ktilde", 
               RowBox[{"1", "+", "t"}]], ",", "acc"}], "]"}]}], "-", 
           RowBox[{
            RowBox[{"(", 
             RowBox[{"1", "-", "\[Delta]"}], ")"}], 
            RowBox[{"SetPrecision", "[", " ", 
             RowBox[{
              SubscriptBox["ktilde", "t"], ",", "acc"}], "]"}]}]}], ")"}], 
         "-", 
         RowBox[{
          RowBox[{"afunc", "[", "t", "]"}], "*", " ", 
          RowBox[{"(", 
           RowBox[{
            RowBox[{"SetPrecision", "[", 
             RowBox[{
              SubscriptBox["gN", 
               RowBox[{"1", "+", "t"}]], ",", "acc"}], "]"}], "-", 
            RowBox[{"Piefunc", "[", "t", "]"}]}], " ", ")"}]}]}]}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"relonealphabeta", "[", 
        RowBox[{"t_", ",", "j_"}], "]"}], ":=", 
       RowBox[{
        RowBox[{"relonealphabeta", "[", 
         RowBox[{"t", ",", "j"}], "]"}], "=", 
        RowBox[{"SetPrecision", "[", 
         RowBox[{
          FractionBox[
           RowBox[{"1", "-", "\[Alpha]", "-", 
            RowBox[{
             RowBox[{"SetPrecision", "[", 
              RowBox[{
               SubscriptBox["\[Beta]", "j"], ",", "acc"}], "]"}], "*", 
             RowBox[{"(", 
              RowBox[{"\[Omega]", "+", 
               RowBox[{
                RowBox[{"(", 
                 RowBox[{"1", "-", "\[Omega]"}], ")"}], " ", 
                RowBox[{"Piefunc", "[", "t", "]"}]}]}], ")"}]}]}], 
           RowBox[{"1", "-", "\[Alpha]", "-", 
            RowBox[{
             RowBox[{"SetPrecision", "[", 
              RowBox[{
               SubscriptBox["\[Beta]", "1"], ",", "acc"}], "]"}], "*", 
             RowBox[{"(", 
              RowBox[{"\[Omega]", "+", 
               RowBox[{
                RowBox[{"(", 
                 RowBox[{"1", "-", "\[Omega]"}], ")"}], " ", 
                RowBox[{"Piefunc", "[", "t", "]"}]}]}], ")"}]}]}]], ",", 
          "acc"}], "]"}]}]}], ";", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"relbeta", "[", 
        RowBox[{"t_", ",", "j_"}], "]"}], ":=", 
       RowBox[{
        RowBox[{"relbeta", "[", 
         RowBox[{"t", ",", "j"}], "]"}], "=", 
        RowBox[{"SetPrecision", "[", 
         RowBox[{
          SuperscriptBox[
           RowBox[{"(", 
            RowBox[{"SetPrecision", "[", 
             RowBox[{
              FractionBox[
               SubscriptBox["\[Beta]", "j"], 
               SubscriptBox["\[Beta]", "1"]], ",", "acc"}], "]"}], ")"}], 
           "t"], ",", "acc"}], "]"}]}]}], ";", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"helper", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"helper", "[", "t", "]"}], "=", 
        RowBox[{"SetPrecision", "[", 
         RowBox[{
          RowBox[{"(", 
           RowBox[{
            UnderoverscriptBox["\[Sum]", 
             RowBox[{"j", "=", "1"}], "nTypes"], 
            RowBox[{"SetPrecision", "[", 
             RowBox[{
              RowBox[{"(", 
               RowBox[{
                SubscriptBox["relN0", "j"], "*", 
                RowBox[{"relbeta", "[", 
                 RowBox[{"t", ",", "j"}], "]"}], "*", 
                FractionBox[
                 RowBox[{"relonealphabeta", "[", 
                  RowBox[{"t", ",", "j"}], "]"}], 
                 RowBox[{" ", 
                  RowBox[{"relonealphabeta", "[", 
                   RowBox[{"0", ",", "j"}], "]"}]}]]}], ")"}], ",", "acc"}], 
             "]"}]}], ")"}], ",", "acc"}], "]"}]}]}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"helper2", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"helper2", "[", "t", "]"}], "=", 
        RowBox[{"SetPrecision", "[", 
         RowBox[{
          RowBox[{"(", 
           RowBox[{
            UnderoverscriptBox["\[Sum]", 
             RowBox[{"j", "=", "1"}], "nTypes"], 
            RowBox[{"SetPrecision", "[", 
             RowBox[{
              RowBox[{
               SubscriptBox["relctilde0", "j"], "*", 
               RowBox[{"relbeta", "[", 
                RowBox[{"t", ",", "j"}], "]"}]}], ",", "acc"}], "]"}]}], 
           ")"}], ",", "acc"}], "]"}]}]}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"eqs1", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{
         RowBox[{
          SubscriptBox["\[Beta]", "1"], 
          RowBox[{"(", 
           RowBox[{"\[Omega]", "+", 
            RowBox[{
             RowBox[{"(", 
              RowBox[{"1", "-", "\[Omega]"}], ")"}], " ", 
             RowBox[{"Piefunc", "[", 
              RowBox[{"t", "+", "1"}], "]"}]}]}], ")"}], 
          RowBox[{"(", 
           RowBox[{
            RowBox[{"(", 
             RowBox[{"1", "-", "\[Delta]"}], ")"}], "+", 
            RowBox[{"r", "[", 
             RowBox[{"t", "+", "1"}], "]"}]}], ")"}], 
          FractionBox[
           RowBox[{"helper2", "[", 
            RowBox[{"t", "+", "1"}], "]"}], 
           RowBox[{"helper2", "[", "t", "]"}]], 
          RowBox[{"Cetilde", "[", "t", "]"}]}], "-", 
         RowBox[{
          RowBox[{"Cetilde", "[", 
           RowBox[{"t", "+", "1"}], "]"}], "*", 
          SuperscriptBox[
           RowBox[{"gDee", "[", 
            RowBox[{"t", "+", "1"}], "]"}], 
           FractionBox["1", 
            RowBox[{"1", "-", "\[Nu]"}]]], 
          SubscriptBox["gN", 
           RowBox[{"t", "+", "1"}]]}]}], "\[Equal]", "0"}]}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"eqs2", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{
         RowBox[{"\[Alpha]", " ", 
          SubscriptBox["\[Beta]", "1"], 
          RowBox[{"(", 
           RowBox[{"\[Omega]", "+", 
            RowBox[{
             RowBox[{"(", 
              RowBox[{"1", "-", "\[Omega]"}], ")"}], " ", 
             RowBox[{"Piefunc", "[", 
              RowBox[{"t", "+", "1"}], "]"}]}]}], ")"}], 
          RowBox[{"(", 
           RowBox[{
            RowBox[{"wtilde", "[", 
             RowBox[{"1", "+", "t"}], "]"}], "+", 
            RowBox[{
             RowBox[{"Piefunc", "[", 
              RowBox[{"t", "+", "1"}], "]"}], "*", 
             RowBox[{"afunc", "[", 
              RowBox[{"t", "+", "1"}], "]"}]}]}], ")"}], "*", 
          RowBox[{"Cetilde", "[", "t", "]"}]}], "+", 
         RowBox[{
          RowBox[{"(", 
           RowBox[{"1", "-", "\[Alpha]", "-", 
            RowBox[{
             SubscriptBox["\[Beta]", "1"], 
             RowBox[{"(", 
              RowBox[{"\[Omega]", "+", 
               RowBox[{
                RowBox[{"(", 
                 RowBox[{"1", "-", "\[Omega]"}], ")"}], " ", 
                RowBox[{"Piefunc", "[", 
                 RowBox[{"t", "+", "1"}], "]"}]}]}], ")"}]}]}], ")"}], 
          FractionBox[
           RowBox[{"helper", "[", 
            RowBox[{"t", "+", "1"}], "]"}], 
           RowBox[{"helper2", "[", 
            RowBox[{"t", "+", "1"}], "]"}]], "*", 
          RowBox[{"Cetilde", "[", 
           RowBox[{"t", "+", "1"}], "]"}], "*", 
          RowBox[{"Cetilde", "[", "t", "]"}]}], "-", 
         RowBox[{"\[Alpha]", " ", 
          RowBox[{"Cetilde", "[", 
           RowBox[{"t", "+", "1"}], "]"}], 
          SubscriptBox["gN", 
           RowBox[{"t", "+", "1"}]], "*", 
          RowBox[{"afunc", "[", "t", "]"}], "*", 
          FractionBox[
           RowBox[{"helper2", "[", "t", "]"}], 
           RowBox[{"helper2", "[", 
            RowBox[{"t", "+", "1"}], "]"}]]}]}], "\[Equal]", "0"}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{
       SubscriptBox["gN", 
        RowBox[{"time", "+", "1"}]], "=", "gNss"}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{
       SubscriptBox["ktilde", 
        RowBox[{"time", "+", "1"}]], "=", "ktildess"}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{"(*", 
       RowBox[{
        RowBox[{
         SubscriptBox["gN", 
          RowBox[{"time", "+", "1"}]], "=", 
         SubscriptBox["gN", "time"]}], ";", "\[IndentingNewLine]", 
        RowBox[{
         SubscriptBox["ktilde", 
          RowBox[{"time", "+", "1"}]], "=", 
         SubscriptBox["ktilde", "time"]}], ";"}], "*)"}], 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"If", "[", 
       RowBox[{
        RowBox[{
         RowBox[{"Length", "[", "pVector", "]"}], "\[Equal]", "19"}], ",", 
        "\[IndentingNewLine]", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"answerTemp", "=", 
          RowBox[{"FindRoot", "[", 
           RowBox[{
            RowBox[{"Join", "[", 
             RowBox[{
              RowBox[{"Table", "[", 
               RowBox[{
                RowBox[{"eqs2", "[", "t", "]"}], ",", 
                RowBox[{"{", 
                 RowBox[{"t", ",", 
                  RowBox[{"-", "1"}], ",", 
                  RowBox[{"time", "-", "1"}]}], "}"}]}], "]"}], ",", 
              RowBox[{"Table", "[", 
               RowBox[{
                RowBox[{"eqs1", "[", "t", "]"}], ",", 
                RowBox[{"{", 
                 RowBox[{"t", ",", 
                  RowBox[{"-", "1"}], ",", 
                  RowBox[{"time", "-", "1"}]}], "}"}]}], "]"}]}], "]"}], ",", 
            RowBox[{"Join", "[", 
             RowBox[{
              RowBox[{"Table", "[", 
               RowBox[{
                RowBox[{"{", 
                 RowBox[{
                  SubscriptBox["gN", "i"], ",", 
                  RowBox[{"(", 
                   RowBox[{
                    SubscriptBox["gN", "i"], "/.", "initPoint"}], ")"}]}], 
                 "}"}], ",", 
                RowBox[{"{", 
                 RowBox[{"i", ",", "0", ",", "time"}], "}"}]}], "]"}], ",", 
              RowBox[{"Table", "[", 
               RowBox[{
                RowBox[{"{", 
                 RowBox[{
                  SubscriptBox["ktilde", "i"], ",", 
                  RowBox[{"(", 
                   RowBox[{
                    SubscriptBox["ktilde", "i"], "/.", "initPoint"}], ")"}]}],
                  "}"}], ",", 
                RowBox[{"{", 
                 RowBox[{"i", ",", "0", ",", "time"}], "}"}]}], "]"}]}], 
             "]"}], ",", 
            RowBox[{"MaxIterations", "\[Rule]", "1000"}]}], "]"}]}], ";"}], 
        "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
        ",", "\[IndentingNewLine]", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"answerTemp", "=", 
          RowBox[{"FindRoot", "[", 
           RowBox[{
            RowBox[{"Join", "[", 
             RowBox[{
              RowBox[{"Table", "[", 
               RowBox[{
                RowBox[{"eqs2", "[", "t", "]"}], ",", 
                RowBox[{"{", 
                 RowBox[{"t", ",", 
                  RowBox[{"-", "1"}], ",", 
                  RowBox[{"time", "-", "1"}]}], "}"}]}], "]"}], ",", 
              RowBox[{"Table", "[", 
               RowBox[{
                RowBox[{"eqs1", "[", "t", "]"}], ",", 
                RowBox[{"{", 
                 RowBox[{"t", ",", 
                  RowBox[{"-", "1"}], ",", 
                  RowBox[{"time", "-", "1"}]}], "}"}]}], "]"}]}], "]"}], ",", 
            RowBox[{"Join", "[", 
             RowBox[{
              RowBox[{"Table", "[", 
               RowBox[{
                RowBox[{"{", 
                 RowBox[{
                  SubscriptBox["gN", "i"], ",", "0.64", ",", "0.4", ",", 
                  "2"}], "}"}], ",", 
                RowBox[{"{", 
                 RowBox[{"i", ",", "0", ",", "time"}], "}"}]}], "]"}], ",", 
              RowBox[{"Table", "[", 
               RowBox[{
                RowBox[{"{", 
                 RowBox[{
                  SubscriptBox["ktilde", "i"], ",", "0.07"}], "}"}], ",", 
                RowBox[{"{", 
                 RowBox[{"i", ",", "0", ",", "time"}], "}"}]}], "]"}]}], 
             "]"}], ",", 
            RowBox[{"MaxIterations", "\[Rule]", "1000"}]}], "]"}]}], ";"}]}], 
       "\[IndentingNewLine]", "\[IndentingNewLine]", "]"}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{"answerR", "=", 
       RowBox[{
        RowBox[{"Table", "[", 
         RowBox[{
          RowBox[{
           SubscriptBox["R", "t"], "\[Rule]", 
           RowBox[{"1", "-", "\[Delta]", "+", 
            RowBox[{"r", "[", "t", "]"}]}]}], ",", 
          RowBox[{"{", 
           RowBox[{"t", ",", "0", ",", "time"}], "}"}]}], "]"}], "/.", 
        "answerTemp"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"eN", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"eN", "[", "t", "]"}], "=", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"t", "==", 
           RowBox[{"-", "1"}]}], ",", "N0", ",", 
          RowBox[{"If", "[", 
           RowBox[{
            RowBox[{"t", "\[LessEqual]", "time"}], ",", 
            RowBox[{
             RowBox[{"(", 
              RowBox[{
               SubscriptBox["gN", "t"], "/.", "answerTemp"}], ")"}], "*", 
             RowBox[{"eN", "[", 
              RowBox[{"t", "-", "1"}], "]"}]}], ",", 
            RowBox[{"gNss", "*", 
             RowBox[{"eN", "[", 
              RowBox[{"t", "-", "1"}], "]"}]}]}], "]"}]}], "]"}]}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"Nii", "[", 
        RowBox[{"i_", ",", "t_"}], "]"}], ":=", 
       RowBox[{
        RowBox[{"Nii", "[", 
         RowBox[{"i", ",", "t"}], "]"}], "=", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"t", "\[LessEqual]", "time"}], ",", 
          RowBox[{
           FractionBox[
            RowBox[{"(", 
             RowBox[{
              SubscriptBox["relN0", "i"], "*", 
              RowBox[{"relbeta", "[", 
               RowBox[{"t", ",", "i"}], "]"}], "*", 
              FractionBox[
               RowBox[{"relonealphabeta", "[", 
                RowBox[{"t", ",", "i"}], "]"}], 
               RowBox[{"relonealphabeta", "[", 
                RowBox[{"0", ",", "i"}], "]"}]]}], ")"}], 
            RowBox[{"helper", "[", "t", "]"}]], "*", 
           RowBox[{"eN", "[", "t", "]"}]}], ",", 
          RowBox[{"If", "[", 
           RowBox[{
            RowBox[{"i", "\[Equal]", "1"}], ",", 
            RowBox[{"eN", "[", "t", "]"}], ",", "0"}], "]"}]}], "]"}]}]}], 
      ";", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"citilde", "[", 
        RowBox[{"i_", ",", "t_"}], "]"}], ":=", 
       RowBox[{
        RowBox[{"citilde", "[", 
         RowBox[{"i", ",", "t"}], "]"}], "=", 
        RowBox[{
         RowBox[{
          RowBox[{"SetPrecision", "[", 
           RowBox[{
            FractionBox[
             RowBox[{"SetPrecision", "[", 
              RowBox[{
               RowBox[{
                SubscriptBox["relctilde0", "i"], "*", 
                RowBox[{"relbeta", "[", 
                 RowBox[{"t", ",", "i"}], "]"}]}], ",", "acc"}], "]"}], 
             RowBox[{"helper2", "[", "t", "]"}]], ",", "acc"}], "]"}], "*", 
          RowBox[{"Cetilde", "[", "t", "]"}]}], "/.", "answerTemp"}]}]}], ";",
       "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"(*", 
       RowBox[{
        RowBox[{
         RowBox[{"--", 
          RowBox[{"--", "Can"}]}], " ", "comment", " ", "out", " ", "the", 
         " ", "below", " ", "if", " ", "not", " ", "looking", " ", "at", " ", 
         RowBox[{
          RowBox[{"distributions", "--"}], "--"}]}], "-"}], "*)"}], 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"For", "[", 
       RowBox[{
        RowBox[{"i", "=", "1"}], ",", 
        RowBox[{"i", "\[LessEqual]", "nTypes"}], ",", 
        RowBox[{"i", "++"}], ",", "\[IndentingNewLine]", 
        "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"If", "[", 
          RowBox[{
           RowBox[{"i", "\[Equal]", "1"}], ",", 
           RowBox[{
            SubscriptBox["kitilde", 
             RowBox[{"i", ",", 
              RowBox[{"time", "+", "1"}]}]], "=", "ktildess"}], ",", 
           RowBox[{
            SubscriptBox["kitilde", 
             RowBox[{"i", ",", 
              RowBox[{"time", "+", "1"}]}]], "=", "0"}]}], "]"}], ";"}]}], 
       "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"eqs3", "[", 
        RowBox[{"i_", ",", "t_"}], "]"}], ":=", 
       RowBox[{"SetPrecision", "[", 
        RowBox[{
         RowBox[{
          RowBox[{
           SubscriptBox["kitilde", 
            RowBox[{"i", ",", "t"}]], "==", 
           RowBox[{
            FractionBox["1", 
             RowBox[{"(", 
              RowBox[{"1", "-", "\[Delta]", "+", 
               RowBox[{"r", "[", "t", "]"}]}], ")"}]], 
            RowBox[{"(", 
             RowBox[{
              RowBox[{"citilde", "[", 
               RowBox[{"i", ",", "t"}], "]"}], "-", 
              RowBox[{
               RowBox[{"(", 
                RowBox[{
                 RowBox[{"wtilde", "[", "t", "]"}], "+", 
                 RowBox[{
                  RowBox[{"afunc", "[", "t", "]"}], "*", 
                  RowBox[{"Piefunc", "[", "t", "]"}]}]}], ")"}], "*", 
               FractionBox[
                RowBox[{"Nii", "[", 
                 RowBox[{"i", ",", "t"}], "]"}], 
                RowBox[{"eN", "[", "t", "]"}]]}], "+", 
              RowBox[{
               SubscriptBox["gN", 
                RowBox[{"t", "+", "1"}]], 
               RowBox[{"(", 
                RowBox[{
                 RowBox[{
                  RowBox[{"afunc", "[", "t", "]"}], "*", 
                  FractionBox[
                   RowBox[{"Nii", "[", 
                    RowBox[{"i", ",", 
                    RowBox[{"t", "+", "1"}]}], "]"}], 
                   RowBox[{"eN", "[", 
                    RowBox[{"t", "+", "1"}], "]"}]]}], "+", 
                 RowBox[{
                  SubscriptBox["kitilde", 
                   RowBox[{"i", ",", 
                    RowBox[{"t", "+", "1"}]}]], "*", 
                  SuperscriptBox[
                   RowBox[{"gDee", "[", 
                    RowBox[{"t", "+", "1"}], "]"}], 
                   FractionBox["1", 
                    RowBox[{"1", "-", "\[Nu]"}]]]}]}], ")"}]}]}], ")"}]}]}], "/.",
           "answerTemp"}], ",", "acc"}], "]"}]}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"answerkitilde", "=", 
       RowBox[{"Table", "[", 
        RowBox[{
         RowBox[{"Solve", "[", 
          RowBox[{
           RowBox[{"Table", "[", 
            RowBox[{
             RowBox[{"eqs3", "[", 
              RowBox[{"j", ",", "t"}], "]"}], ",", 
             RowBox[{"{", 
              RowBox[{"t", ",", "0", ",", "time"}], "}"}]}], "]"}], ",", 
           RowBox[{"Table", "[", 
            RowBox[{
             SubscriptBox["kitilde", 
              RowBox[{"j", ",", "t"}]], ",", 
             RowBox[{"{", 
              RowBox[{"t", ",", "0", ",", "time"}], "}"}]}], "]"}]}], "]"}], 
         ",", 
         RowBox[{"{", 
          RowBox[{"j", ",", "1", ",", "nTypes"}], "}"}]}], "]"}]}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"kiitilde", "[", 
        RowBox[{"i_", ",", "t_"}], "]"}], ":=", 
       RowBox[{
        RowBox[{"kiitilde", "[", 
         RowBox[{"i", ",", "t"}], "]"}], "=", 
        RowBox[{"answerkitilde", "[", 
         RowBox[{"[", 
          RowBox[{"i", ",", "1", ",", 
           RowBox[{"t", "+", "1"}], ",", "2"}], "]"}], "]"}]}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"CetildeN", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"CetildeN", "[", "t", "]"}], "=", 
        RowBox[{"SetPrecision", "[", 
         RowBox[{
          RowBox[{
           RowBox[{"Cetilde", "[", "t", "]"}], "/.", "answerTemp"}], ",", 
          "acc"}], "]"}]}]}], ";", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"rN", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"rN", "[", "t", "]"}], "=", 
        RowBox[{"SetPrecision", "[", 
         RowBox[{
          RowBox[{
           RowBox[{"r", "[", "t", "]"}], "/.", "answerTemp"}], ",", "acc"}], 
         "]"}]}]}], ";", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"wtildeN", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"wtildeN", "[", "t", "]"}], "=", 
        RowBox[{"SetPrecision", "[", 
         RowBox[{
          RowBox[{
           RowBox[{"wtilde", "[", "t", "]"}], "/.", "answerTemp"}], ",", 
          "acc"}], "]"}]}]}], ";", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"afuncN", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"afuncN", "[", "t", "]"}], "=", 
        RowBox[{"SetPrecision", "[", 
         RowBox[{
          RowBox[{
           RowBox[{"afunc", "[", "t", "]"}], "/.", "answerTemp"}], ",", 
          "acc"}], "]"}]}]}], ";", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"wap", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"wap", "[", "t", "]"}], "=", 
        RowBox[{"SetPrecision", "[", 
         RowBox[{
          RowBox[{"(", 
           FractionBox[
            RowBox[{
             RowBox[{"wtildeN", "[", "t", "]"}], "+", 
             RowBox[{
              RowBox[{"afuncN", "[", "t", "]"}], "*", 
              RowBox[{"Piefunc", "[", "t", "]"}]}]}], 
            RowBox[{"eN", "[", "t", "]"}]], ")"}], ",", "acc"}], "]"}]}]}], 
      ";", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"helpersums", "[", 
        RowBox[{"i_", ",", "t_"}], "]"}], ":=", 
       RowBox[{
        RowBox[{"helpersums", "[", 
         RowBox[{"i", ",", "t"}], "]"}], "=", 
        RowBox[{"SetPrecision", "[", 
         RowBox[{
          RowBox[{
           RowBox[{"(", 
            RowBox[{
             RowBox[{
              RowBox[{"wap", "[", "t", "]"}], "*", 
              RowBox[{"Nii", "[", 
               RowBox[{"i", ",", "t"}], "]"}]}], "-", 
             RowBox[{
              SubscriptBox["gN", 
               RowBox[{"t", "+", "1"}]], 
              RowBox[{"afuncN", "[", "t", "]"}], "*", 
              FractionBox[
               RowBox[{"Nii", "[", 
                RowBox[{"i", ",", 
                 RowBox[{"t", "+", "1"}]}], "]"}], 
               RowBox[{"eN", "[", 
                RowBox[{"t", "+", "1"}], "]"}]]}]}], ")"}], "/.", 
           "answerTemp"}], ",", "acc"}], "]"}]}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"(*", 
       RowBox[{
        RowBox[{
         RowBox[{"kitildeN", "[", 
          RowBox[{"i_", ",", "t_"}], "]"}], ":=", 
         RowBox[{"If", "[", 
          RowBox[{
           RowBox[{"t", "==", "0"}], ",", 
           SubscriptBox["kitilde", 
            RowBox[{"i", ",", "0"}]], ",", 
           RowBox[{"kiitilde", "[", 
            RowBox[{"i", ",", "t"}], "]"}]}], "]"}]}], ";"}], "*)"}], 
      "\[IndentingNewLine]", 
      RowBox[{"(*", 
       RowBox[{
        RowBox[{
         RowBox[{"kitildeN", "[", 
          RowBox[{"i_", ",", "t_"}], "]"}], ":=", 
         RowBox[{"kiitilde", "[", 
          RowBox[{"i", ",", "t"}], "]"}]}], ";"}], "*)"}], 
      "\[IndentingNewLine]", 
      RowBox[{"(*", 
       RowBox[{
        RowBox[{
         RowBox[{"citildex", "[", 
          RowBox[{"i_", ",", "t_"}], "]"}], ":=", 
         RowBox[{
          RowBox[{
           RowBox[{"(", 
            RowBox[{"1", "-", "\[Delta]", "+", 
             RowBox[{"rN", "[", "t", "]"}]}], ")"}], 
           RowBox[{"kiitilde", "[", 
            RowBox[{"i", ",", "t"}], "]"}]}], "+", 
          RowBox[{
           RowBox[{"(", 
            RowBox[{
             RowBox[{"wtildeN", "[", "t", "]"}], "+", 
             RowBox[{
              RowBox[{"afuncN", "[", "t", "]"}], "*", 
              RowBox[{"Piefunc", "[", "t", "]"}]}]}], ")"}], "*", 
           FractionBox[
            RowBox[{"Nii", "[", 
             RowBox[{"i", ",", "t"}], "]"}], 
            RowBox[{"eN", "[", "t", "]"}]]}], "-", 
          RowBox[{
           SubscriptBox["gN", 
            RowBox[{"t", "+", "1"}]], 
           RowBox[{"(", 
            RowBox[{
             RowBox[{
              RowBox[{"afuncN", "[", "t", "]"}], "*", 
              FractionBox[
               RowBox[{"Nii", "[", 
                RowBox[{"i", ",", 
                 RowBox[{"t", "+", "1"}]}], "]"}], 
               RowBox[{"eN", "[", 
                RowBox[{"t", "+", "1"}], "]"}]]}], "+", 
             RowBox[{
              RowBox[{"kiitilde", "[", 
               RowBox[{"i", ",", 
                RowBox[{"t", "+", "1"}]}], "]"}], "*", 
              SuperscriptBox[
               RowBox[{"gDee", "[", 
                RowBox[{"t", "+", "1"}], "]"}], 
               FractionBox["1", 
                RowBox[{"1", "-", "\[Nu]"}]]]}]}], ")"}]}]}]}], ";"}], "*)"}],
       "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"citildex", "[", 
        RowBox[{"i_", ",", "t_"}], "]"}], ":=", 
       RowBox[{"SetPrecision", "[", 
        RowBox[{
         RowBox[{
          RowBox[{"citildex", "[", 
           RowBox[{"i", ",", "t"}], "]"}], "=", 
          RowBox[{
           RowBox[{"(", 
            RowBox[{
             RowBox[{
              RowBox[{"(", 
               RowBox[{"1", "-", "\[Delta]", "+", 
                RowBox[{"rN", "[", "t", "]"}]}], ")"}], 
              RowBox[{"kiitilde", "[", 
               RowBox[{"i", ",", "t"}], "]"}]}], "+", 
             RowBox[{"helpersums", "[", 
              RowBox[{"i", ",", "t"}], "]"}], "-", 
             RowBox[{
              SubscriptBox["gN", 
               RowBox[{"t", "+", "1"}]], 
              RowBox[{"kiitilde", "[", 
               RowBox[{"i", ",", 
                RowBox[{"t", "+", "1"}]}], "]"}], "*", 
              SuperscriptBox[
               RowBox[{"gDee", "[", 
                RowBox[{"t", "+", "1"}], "]"}], 
               FractionBox["1", 
                RowBox[{"1", "-", "\[Nu]"}]]]}]}], ")"}], "/.", 
           "answerTemp"}]}], ",", "acc"}], "]"}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"ansDif", "=", 
       RowBox[{"(", 
        RowBox[{"Table", "[", 
         RowBox[{
          RowBox[{
           FractionBox[
            RowBox[{"citildex", "[", 
             RowBox[{"i", ",", "0"}], "]"}], 
            RowBox[{"citilde", "[", 
             RowBox[{"i", ",", "0"}], "]"}]], "-", "1"}], ",", 
          RowBox[{"{", 
           RowBox[{"i", ",", "1", ",", "nTypes"}], "}"}]}], "]"}], ")"}]}], 
      ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"answergN", "=", 
       RowBox[{"Table", "[", 
        RowBox[{
         RowBox[{
          SubscriptBox["gN", "t"], "\[Rule]", 
          RowBox[{"(", 
           RowBox[{
            SubscriptBox["gN", "t"], "/.", "answerTemp"}], ")"}]}], ",", 
         RowBox[{"{", 
          RowBox[{"t", ",", "0", ",", "time"}], "}"}]}], "]"}]}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{"answerktilde", "=", 
       RowBox[{"Table", "[", 
        RowBox[{
         RowBox[{
          SubscriptBox["ktilde", "t"], "\[Rule]", 
          RowBox[{"(", 
           RowBox[{
            SubscriptBox["ktilde", "t"], "/.", "answerTemp"}], ")"}]}], ",", 
         RowBox[{"{", 
          RowBox[{"t", ",", "0", ",", "time"}], "}"}]}], "]"}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"answer", "=", 
       RowBox[{"Table", "[", 
        RowBox[{
         RowBox[{"{", 
          RowBox[{
           RowBox[{"Table", "[", 
            RowBox[{
             RowBox[{
              SubscriptBox["Ni", 
               RowBox[{"j", ",", "t"}]], "\[Rule]", 
              RowBox[{"Nii", "[", 
               RowBox[{"j", ",", "t"}], "]"}]}], ",", 
             RowBox[{"{", 
              RowBox[{"j", ",", "1", ",", "nTypes"}], "}"}]}], "]"}], ",", 
           RowBox[{"Table", "[", 
            RowBox[{
             RowBox[{
              SubscriptBox["kitilde", 
               RowBox[{"j", ",", "t"}]], "\[Rule]", 
              RowBox[{"kiitilde", "[", 
               RowBox[{"j", ",", "t"}], "]"}]}], ",", 
             RowBox[{"{", 
              RowBox[{"j", ",", "1", ",", "nTypes"}], "}"}]}], "]"}], ",", 
           RowBox[{"Table", "[", 
            RowBox[{
             RowBox[{
              SubscriptBox["\[Beta]", 
               RowBox[{"j", ",", "t"}]], "\[Rule]", 
              SubscriptBox["\[Beta]", "j"]}], ",", 
             RowBox[{"{", 
              RowBox[{"j", ",", "1", ",", "nTypes"}], "}"}]}], "]"}], ",", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{
              SubscriptBox["R", "t"], "\[Rule]", 
              RowBox[{"(", 
               RowBox[{"1", "-", "\[Delta]", "+", 
                RowBox[{"r", "[", "t", "]"}]}], ")"}]}], "/.", "answerTemp"}],
             "}"}], ",", 
           RowBox[{"Table", "[", 
            RowBox[{
             RowBox[{
              SubscriptBox["ciitildeshare", 
               RowBox[{"j", ",", "t"}]], "\[Rule]", 
              FractionBox[
               RowBox[{"citilde", "[", 
                RowBox[{"j", ",", "t"}], "]"}], 
               RowBox[{"CetildeN", "[", "t", "]"}]]}], ",", 
             RowBox[{"{", 
              RowBox[{"j", ",", "1", ",", "nTypes"}], "}"}]}], "]"}], ",", 
           RowBox[{
            SubscriptBox["gN", "t"], "\[Rule]", 
            RowBox[{"(", 
             RowBox[{
              SubscriptBox["gN", "t"], "/.", "answerTemp"}], ")"}]}], ",", 
           RowBox[{
            SubscriptBox["ktilde", "t"], "\[Rule]", 
            RowBox[{"(", 
             RowBox[{
              SubscriptBox["ktilde", "t"], "/.", "answerTemp"}], ")"}]}]}], 
          "}"}], ",", 
         RowBox[{"{", 
          RowBox[{"t", ",", "0", ",", "time"}], "}"}]}], "]"}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"Print", "[", 
       RowBox[{"Total", "[", 
        RowBox[{"Table", "[", 
         RowBox[{
          FractionBox[
           RowBox[{"citilde", "[", 
            RowBox[{"j", ",", "29"}], "]"}], 
           RowBox[{"CetildeN", "[", "29", "]"}]], ",", 
          RowBox[{"{", 
           RowBox[{"j", ",", "1", ",", "nTypes"}], "}"}]}], "]"}], "]"}], 
       "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{
       SubscriptBox["ktilde", 
        RowBox[{"time", "+", "1"}]], "=."}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{
       SubscriptBox["ax", 
        RowBox[{"time", "+", "1"}]], "=."}], ";", "\[IndentingNewLine]", 
      RowBox[{
       SubscriptBox["ktilde", 
        RowBox[{"-", "1"}]], "=."}], ";", "\[IndentingNewLine]", 
      RowBox[{
       SubscriptBox["ax", "time"], "=."}], ";", "\[IndentingNewLine]", 
      RowBox[{
       SubscriptBox["gN", 
        RowBox[{"time", "+", "1"}]], "=."}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"For", "[", 
       RowBox[{
        RowBox[{"i", "=", "1"}], ",", 
        RowBox[{"i", "\[LessEqual]", "nTypes"}], ",", 
        RowBox[{"i", "++"}], ",", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{
          SubscriptBox["relN0", "i"], "=."}], ";", 
         RowBox[{
          SubscriptBox["propN", "i"], "=."}], ";", 
         RowBox[{
          SubscriptBox["\[Beta]", "i"], "=."}], ";", 
         RowBox[{
          SubscriptBox["relctilde0", "i"], "=."}], ";", "\[IndentingNewLine]", 
         RowBox[{
          SubscriptBox["kitilde", 
           RowBox[{"i", ",", 
            RowBox[{"time", "+", "1"}]}]], "=."}], ";"}]}], 
       "\[IndentingNewLine]", "\[IndentingNewLine]", "]"}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"Remove", "[", 
       RowBox[{
       "pVectorAll", ",", "pVector", ",", "\[IndentingNewLine]", "\[Alpha]", 
        ",", "\[Beta]A", ",", "\[Beta]B", ",", "Pie", ",", "time", ",", 
        "\[Xi]", ",", "\[Nu]", ",", "\[IndentingNewLine]", 
        "\[IndentingNewLine]", "wtilde", ",", "r", ",", "Cetilde", ",", 
        "citilde", ",", "gDee", ",", "eN", ",", "kiitilde", ",", "Dee", ",", 
        "afunc", ",", "ass", ",", "Deefuncx", ",", "\[IndentingNewLine]", 
        "\[IndentingNewLine]", "eqs", ",", "eqs1", ",", "eqs2", ",", "eqs3", 
        ",", "eqs4", ",", "eqs5", ",", "\[IndentingNewLine]", 
        "\[IndentingNewLine]", "eq", ",", "eq1", ",", "eq2", ",", "eq3", ",", 
        "eq4", ",", "eq5", ",", "\[IndentingNewLine]", "\[IndentingNewLine]", 
        "varRelcB0", ",", "answerAllNi", ",", "answerktilde", ",", 
        "answerAllci", ",", "answerAllKi", ",", "answerAllsi", ",", "answerW",
         ",", "points", ",", "answerAllYi", ",", "answerY", ",", "answera", 
        ",", "relbeta", ",", "eNdata", ",", "greN", ",", "answerD", ",", 
        "answersavingsrate", ",", "answerK", ",", "answery", ",", "Piess", 
        ",", "Piefunc", ",", "relonealphabeta", ",", "\[IndentingNewLine]", 
        "\[IndentingNewLine]", "a", ",", " ", "\[Delta]", ",", "N0", ",", 
        "grDee", ",", "gNss", ",", "geN", ",", "ktildess", ",", "ansSS", ",", 
        "answerTemp", ",", "answerkitilde", ",", " ", "answerctilde", ",", 
        "  ", "answerN", ",", "answerp", ",", "answerR", ",", 
        "answerCtildeAg", ",", "vars", ",", " ", "\[Beta]vec", ",", 
        "propNvec", ",", "sorted\[Beta]Location", ",", "nTypes", ",", " ", 
        "acc", ",", "temp", ",", "temp2", ",", "temp3", ",", "tempNp", ",", 
        "helper", ",", "helper2", ",", "helper3", ",", "ci", ",", "Kii", ",", 
        "Nii", ",", "sii", ",", "cij", ",", "Kij", ",", "Nij", ",", "pct", 
        ",", "answerCQuantiles", ",", "answerKQuantiles", ",", 
        "answerNQuantiles", ",", "indexpct", ",", "answerKii", ",", 
        "answerKi", ",", "answerSharesSelectedYears", ",", 
        "answerSocietalBeta", ",", "inityear", ",", "currentyear", ",", 
        "cyperiod", ",", "initPoint", ",", "\[Omega]", ",", "answerFert", ",",
         "rN", ",", "CetildeN", ",", "wtildeN", ",", "afuncN", ",", "wap", 
        ",", "helpersums", ",", "kitildeN", ",", "citildex", ",", "answergN", 
        ",", "aData"}], "]"}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"Return", "[", 
       RowBox[{"{", 
        RowBox[{"ansDif", ",", "answer"}], "}"}], "]"}], ";"}]}], 
    "\[IndentingNewLine]", "]"}]}], ";"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.},
 CellChangeTimes->{{3.5450207567370634`*^9, 3.5450208126640635`*^9}, {
   3.5450213922850633`*^9, 3.545021455795063*^9}, {3.545021499609063*^9, 
   3.5450218859630632`*^9}, {3.545022337398063*^9, 3.545022363188063*^9}, {
   3.545022412753063*^9, 3.545022418451063*^9}, {3.545022458470063*^9, 
   3.545022462352063*^9}, {3.5450226095130634`*^9, 3.5450226831710634`*^9}, {
   3.5450227685530634`*^9, 3.545022796658063*^9}, {3.5450231576000633`*^9, 
   3.545023168904063*^9}, 3.545023328852063*^9, {3.5450235965720634`*^9, 
   3.545023615297063*^9}, 3.545023671896063*^9, 3.545025304915063*^9, {
   3.5452319574236*^9, 3.5452319810069494`*^9}, 3.5452320377051926`*^9, 
   3.5452324327457876`*^9, {3.546864863835182*^9, 3.546864899611182*^9}, 
   3.546864971144182*^9, {3.5468650373641825`*^9, 3.5468650609311824`*^9}, {
   3.546866633771182*^9, 3.5468666428381824`*^9}, {3.5468666796221824`*^9, 
   3.5468666868411827`*^9}, {3.5469414861762*^9, 3.5469414947692003`*^9}, 
   3.5471129347887774`*^9, {3.547113040450777*^9, 3.547113044292777*^9}, 
   3.5471181898287773`*^9, {3.547118969707777*^9, 3.547118976816777*^9}, {
   3.5471212301287775`*^9, 3.547121236237777*^9}, {3.547122382551777*^9, 
   3.547122390632777*^9}, {3.547127642744777*^9, 3.547127646376777*^9}, 
   3.5471281319847775`*^9, {3.547132407191777*^9, 3.547132413044777*^9}, {
   3.547133054195777*^9, 3.547133091931777*^9}, {3.547137681165777*^9, 
   3.5471376947607775`*^9}, 3.547137748890777*^9, {3.7244196368117094`*^9, 
   3.7244196690585537`*^9}, {3.7244199852736397`*^9, 3.72442000432973*^9}, 
   3.7244200575997767`*^9, {3.7244202517508817`*^9, 3.7244202524669228`*^9}, {
   3.7244202983375463`*^9, 3.7244202987585707`*^9}, {3.724422768788848*^9, 
   3.724422780798535*^9}, {3.724423196621319*^9, 3.7244232028736763`*^9}, {
   3.7244235236850257`*^9, 3.724423541280032*^9}, {3.724423603039564*^9, 
   3.724423603252577*^9}, {3.72442401819231*^9, 3.7244240721423955`*^9}, {
   3.724425328541513*^9, 3.72442533083232*^9}, {3.724479631636307*^9, 
   3.7244799070073957`*^9}, {3.7244800117084045`*^9, 3.724480165149476*^9}, {
   3.724480222995779*^9, 3.7244802376004047`*^9}, {3.724480279496479*^9, 
   3.724480318614748*^9}, {3.724480412895115*^9, 3.7244804508971825`*^9}, {
   3.7244804896596518`*^9, 3.7244805495495577`*^9}, {3.7244805910118313`*^9, 
   3.724480611153466*^9}, {3.724480755982724*^9, 3.7244807590715294`*^9}, {
   3.7244808686808624`*^9, 3.7244808847459183`*^9}, {3.724480916247033*^9, 
   3.7244809360271125`*^9}, {3.724480976263264*^9, 3.724480994060331*^9}, {
   3.7244810560325747`*^9, 3.724481194781082*^9}, {3.7244812255951834`*^9, 
   3.7244813092584925`*^9}, 3.724482642624999*^9, {3.724499784183713*^9, 
   3.7244997889219847`*^9}, {3.724499898947277*^9, 3.7244999067877254`*^9}, {
   3.724500319348323*^9, 3.72450032175146*^9}, {3.724580135076105*^9, 
   3.7245801734072976`*^9}, {3.7259716811998024`*^9, 
   3.7259717026180277`*^9}, {3.7259718195847178`*^9, 3.725971881274246*^9}, {
   3.7259720133337994`*^9, 3.7259720446285896`*^9}, {3.7259728538058715`*^9, 
   3.72597285464992*^9}, {3.725973025874714*^9, 3.725973038702447*^9}, {
   3.7259732006057076`*^9, 3.7259732305034175`*^9}, {3.7259734422325277`*^9, 
   3.725973443425596*^9}, {3.7259736826442785`*^9, 3.725973712402981*^9}, 
   3.725974082252135*^9, {3.725974168099045*^9, 3.725974171697251*^9}, {
   3.725974276747259*^9, 3.7259743103661823`*^9}, {3.725974496668838*^9, 
   3.725974498521944*^9}, 3.7259748561053967`*^9, {3.725975127455917*^9, 
   3.7259751291570144`*^9}, {3.725975210171648*^9, 3.7259752119847517`*^9}, {
   3.725975252817087*^9, 3.7259752548932056`*^9}, {3.7259752864320097`*^9, 
   3.725975289801203*^9}, 3.725975322131052*^9, 3.7259753545829077`*^9, {
   3.7259754974490795`*^9, 3.7259755232805567`*^9}, {3.725975563454855*^9, 
   3.725975588667297*^9}, 3.725975645441544*^9, 3.725975912794836*^9, {
   3.7259767322667065`*^9, 3.7259767777723093`*^9}, {3.7259768351155896`*^9, 
   3.72597683948584*^9}, {3.7259770115736823`*^9, 3.7259770124347315`*^9}, {
   3.725977843585271*^9, 3.7259778513217134`*^9}, 3.7259780865771694`*^9, {
   3.7259782106042633`*^9, 3.725978215138522*^9}, {3.725979573613223*^9, 
   3.725979578259488*^9}, {3.7259796622902946`*^9, 3.7259796627033186`*^9}, {
   3.7259797689373946`*^9, 3.7259797707714996`*^9}, {3.725982056292224*^9, 
   3.7259820623565702`*^9}, {3.7259823008802137`*^9, 3.725982304503421*^9}, 
   3.7259824300226*^9, {3.7259826255427833`*^9, 3.725982633688249*^9}, 
   3.726052533189146*^9, 3.72605654642269*^9, {3.726056584168849*^9, 
   3.726056584394862*^9}, {3.726056735840524*^9, 3.726056842057599*^9}, {
   3.7260569594213123`*^9, 3.726057006338996*^9}, {3.7260573801133747`*^9, 
   3.726057415089375*^9}, {3.7260576067103353`*^9, 3.726057621991209*^9}, {
   3.726057705075961*^9, 3.726057745505274*^9}, {3.7260577882457185`*^9, 
   3.726057788350724*^9}, 3.7260578532684374`*^9, {3.726058168965494*^9, 
   3.726058191954809*^9}, 3.7260584572559834`*^9, 3.7260585510203466`*^9, 
   3.7260586693901167`*^9, {3.7260587136876507`*^9, 3.7260587150287275`*^9}, 
   3.7260587885099297`*^9, {3.7260588803901854`*^9, 3.7260588874085865`*^9}, {
   3.726065395157809*^9, 3.7260654081495523`*^9}, 3.7260656730857053`*^9, 
   3.7261505320115995`*^9, {3.726150817149908*^9, 3.7261508223902082`*^9}, {
   3.7261508610924215`*^9, 3.726150863175541*^9}, {3.7261509226079397`*^9, 
   3.7261509268461823`*^9}, {3.7261510114810233`*^9, 3.7261510127760973`*^9}, 
   3.7261510472260675`*^9, 3.726151239068041*^9, {3.7262219221653395`*^9, 
   3.7262219459126973`*^9}, {3.726572778538774*^9, 3.72657296396938*^9}, {
   3.726575277551709*^9, 3.7265753263424997`*^9}, {3.72657919038251*^9, 
   3.726579245115641*^9}, {3.726579328005382*^9, 3.7265793459474087`*^9}, {
   3.7265794571257677`*^9, 3.7265794576507974`*^9}, {3.7265799193752065`*^9, 
   3.726580062607399*^9}, {3.7265802511051807`*^9, 3.726580253477316*^9}, {
   3.7265802907774496`*^9, 3.7265803011860447`*^9}, 3.726580332100813*^9, 
   3.726580472134823*^9, {3.7266782584229593`*^9, 3.7266782584839625`*^9}, {
   3.7266783520883164`*^9, 3.726678380217925*^9}, {3.7266784821867576`*^9, 
   3.7266784823207655`*^9}, {3.7266787722723494`*^9, 3.726678775699546*^9}, {
   3.7267378871756425`*^9, 3.7267378926259546`*^9}, {3.7267380012321663`*^9, 
   3.7267380443816347`*^9}, 3.7267383395445166`*^9, {3.7267386874814177`*^9, 
   3.726738687681429*^9}, {3.7267444538442345`*^9, 3.7267444738113766`*^9}, {
   3.7267445078853254`*^9, 3.7267445116465406`*^9}, {3.7267457891266084`*^9, 
   3.726745799611208*^9}, 3.726745894313625*^9, {3.7267459474936666`*^9, 
   3.7267459805325565`*^9}, {3.7267460135954475`*^9, 3.72674601364145*^9}, {
   3.7267460666484814`*^9, 3.7267461243247805`*^9}, {3.726746174803668*^9, 
   3.7267461757657228`*^9}, {3.726746250501998*^9, 3.7267462517090664`*^9}, {
   3.726746297312675*^9, 3.726746303088005*^9}, {3.7267463504067116`*^9, 
   3.726746381343481*^9}, {3.7267464139183445`*^9, 3.7267464155854397`*^9}, {
   3.7267464517585087`*^9, 3.7267464864564934`*^9}, 3.726819600791639*^9, {
   3.7268197192754154`*^9, 3.726819719388422*^9}, {3.7268198949364634`*^9, 
   3.72681997041078*^9}, {3.72682000135955*^9, 3.726820003057647*^9}, 
   3.72691757275277*^9, {3.727072630144998*^9, 3.7270726344392433`*^9}, {
   3.7270727025001364`*^9, 3.7270727041672316`*^9}, {3.7270728599741435`*^9, 
   3.727072918786507*^9}, {3.7270729491822457`*^9, 3.7270729909026318`*^9}, {
   3.727073513310512*^9, 3.727073542136161*^9}, {3.727074679458212*^9, 
   3.7270748814547653`*^9}, {3.727075074493807*^9, 3.7270750745778117`*^9}, {
   3.7270945860178022`*^9, 3.7270946626231833`*^9}, {3.7270947251547604`*^9, 
   3.727094761848859*^9}, {3.7270947954997835`*^9, 3.7270948121007333`*^9}, {
   3.7270948538851233`*^9, 3.7270949068631535`*^9}, {3.7270950033696733`*^9, 
   3.727095089821618*^9}, 3.727095232651553*^9, {3.7270952690986376`*^9, 
   3.727095271704787*^9}, {3.727095339118643*^9, 3.7270953396516733`*^9}, {
   3.727095959410121*^9, 3.7270959750520163`*^9}, {3.7270961075605946`*^9, 
   3.7270961520811415`*^9}, {3.727096333395512*^9, 3.7270963427230453`*^9}, {
   3.7270965519610133`*^9, 3.7270966642324347`*^9}, {3.7270967194025908`*^9, 
   3.7270967202946415`*^9}, 3.7270969294026017`*^9, {3.7271625649643507`*^9, 
   3.7271625827703686`*^9}, {3.727162660482814*^9, 3.7271626620939054`*^9}, {
   3.727163375511711*^9, 3.727163405971453*^9}, {3.7271634883771667`*^9, 
   3.7271634889061966`*^9}, {3.727163542124241*^9, 3.7271635923131113`*^9}, {
   3.7271643657323484`*^9, 3.727164372091712*^9}, {3.7271644136430883`*^9, 
   3.7271644879673395`*^9}, 3.727164521644266*^9, {3.727174777862838*^9, 
   3.7271747779968452`*^9}, {3.727359715845685*^9, 3.7273597179218035`*^9}, {
   3.7273599821989193`*^9, 3.7273599829359617`*^9}, 3.7273601710737224`*^9, 
   3.727362167636919*^9, {3.7274230101644087`*^9, 3.727423014298645*^9}, {
   3.727440638677702*^9, 3.7274406636271296`*^9}, 3.7274406964070044`*^9, 
   3.727440731352003*^9, {3.7274407796657662`*^9, 3.7274408067343144`*^9}, {
   3.727510206731958*^9, 3.72751020764401*^9}, 3.7275103904494658`*^9, {
   3.727527978340436*^9, 3.727528016145598*^9}, {3.727535745583697*^9, 
   3.7275357715461817`*^9}, {3.7275519585534515`*^9, 3.727551999871815*^9}, {
   3.727552131153324*^9, 3.7275522351042695`*^9}, {3.727552655918339*^9, 
   3.7275527050771503`*^9}, {3.727552771365942*^9, 3.727552784072669*^9}, {
   3.72755285070848*^9, 3.727552853584645*^9}, {3.727554772658409*^9, 
   3.7275547869542274`*^9}, 3.7610435364817405`*^9, {3.761043571231025*^9, 
   3.761043576165954*^9}, {3.7610436235881033`*^9, 3.7610436413449106`*^9}, {
   3.7610436729002457`*^9, 3.761043770878871*^9}, {3.7610438475156293`*^9, 
   3.7610438647290735`*^9}, {3.7610443741135235`*^9, 3.761044401042234*^9}, {
   3.7618924178069444`*^9, 3.761892420698386*^9}, {3.761892490182556*^9, 
   3.7618924929984612`*^9}, {3.761892545538104*^9, 3.761892574421073*^9}, {
   3.7618943501822863`*^9, 3.761894355806435*^9}, 3.7618944420269365`*^9, {
   3.761894590484105*^9, 3.7618945909553003`*^9}, {3.765706575514555*^9, 
   3.7657065967311754`*^9}, {3.7657069762490983`*^9, 3.765706998624098*^9}, {
   3.7657827346196156`*^9, 3.7657827346804476`*^9}, {3.7657827662081413`*^9, 
   3.765782776262255*^9}, {3.7657828291219053`*^9, 3.7657829030262814`*^9}, {
   3.765792704839733*^9, 3.765792713891528*^9}, {3.7657927941309633`*^9, 
   3.765792854728921*^9}, {3.7657928892486134`*^9, 3.7657929295766582`*^9}, {
   3.765792979001932*^9, 3.7657930204449406`*^9}, {3.7657931294908957`*^9, 
   3.7657931374256454`*^9}, {3.7657931713717318`*^9, 
   3.7657931859776144`*^9}, {3.7657939720100403`*^9, 
   3.7657941210305495`*^9}, {3.7657941752425876`*^9, 
   3.7657942749356403`*^9}, {3.7657943083572693`*^9, 3.765794317829939*^9}, 
   3.76579434791549*^9, {3.765794438973993*^9, 3.7657945077181673`*^9}, {
   3.765795044879264*^9, 3.7657950752816195`*^9}, 3.7657960529456987`*^9, 
   3.7657973933299627`*^9, 3.765866685458251*^9, {3.765866741061284*^9, 
   3.7658667423029637`*^9}, {3.7658675605738115`*^9, 3.765867632896985*^9}, {
   3.76586808998555*^9, 3.7658681576486278`*^9}, {3.765870398400258*^9, 
   3.765870398502982*^9}, {3.765870746165774*^9, 3.765870746206662*^9}, {
   3.765874668191653*^9, 3.765874668660451*^9}, {3.7658747061050673`*^9, 
   3.765874729806857*^9}, {3.765875398319106*^9, 3.765875401117617*^9}, {
   3.765876280541726*^9, 3.76587629695483*^9}, {3.7658763346779566`*^9, 
   3.765876338007025*^9}, {3.765876902981591*^9, 3.7658769609724207`*^9}, {
   3.7658770973194704`*^9, 3.7658770998766603`*^9}, {3.7658771811591372`*^9, 
   3.7658771850627003`*^9}, {3.7658772670901785`*^9, 
   3.7658772777028255`*^9}, {3.765877315014012*^9, 3.765877352872703*^9}, {
   3.765877425541308*^9, 3.765877426344161*^9}, {3.76587748017918*^9, 
   3.765877480255975*^9}, {3.7658775192685795`*^9, 3.765877539390752*^9}, {
   3.7658776192561045`*^9, 3.7658776350189996`*^9}, {3.765877844409308*^9, 
   3.7658778654739313`*^9}, {3.7658781572475634`*^9, 
   3.7658781732168517`*^9}, {3.7658785536763487`*^9, 
   3.7658785537621183`*^9}, {3.765878723204729*^9, 3.7658787278354254`*^9}, {
   3.765878821034837*^9, 3.765878824716008*^9}, {3.7658788602087345`*^9, 
   3.765878906257386*^9}, {3.7658789742188053`*^9, 3.765878977583871*^9}, {
   3.7658790137815223`*^9, 3.7658790168971925`*^9}, {3.7658799376814375`*^9, 
   3.7658799503366623`*^9}, {3.7658802835697455`*^9, 3.765880284330738*^9}, {
   3.7658803589922943`*^9, 3.7658803634055367`*^9}, {3.7658803953571463`*^9, 
   3.765880397842506*^9}, {3.765880428410843*^9, 3.7658804292576137`*^9}, {
   3.7658805076082697`*^9, 3.765880507758868*^9}, {3.7658805416603003`*^9, 
   3.765880560977695*^9}, {3.7658806147939253`*^9, 3.7658806186366596`*^9}, {
   3.765880689523216*^9, 3.7658807745617647`*^9}, {3.7658808085188737`*^9, 
   3.7658808113652554`*^9}, {3.7658808656150513`*^9, 
   3.7658808672945523`*^9}, {3.765884258963793*^9, 3.765884276245948*^9}, {
   3.7658848692984433`*^9, 3.765884895979295*^9}, {3.765884941039137*^9, 
   3.7658849467099524`*^9}, {3.7658850008335857`*^9, 
   3.7658850086916256`*^9}, {3.765885087197223*^9, 3.765885102892359*^9}, {
   3.767001403833307*^9, 3.767001408035447*^9}, 3.767072356048971*^9, {
   3.7670724191411943`*^9, 3.7670724494980583`*^9}, {3.768893865727254*^9, 
   3.768893891122732*^9}, {3.7688945439884176`*^9, 3.768894544740034*^9}, {
   3.7688945986450815`*^9, 3.7688946343340454`*^9}, {3.768894749355147*^9, 
   3.7688947878920264`*^9}, {3.7688949238677526`*^9, 3.768894954747985*^9}, {
   3.7689038263403683`*^9, 3.7689038282929125`*^9}, {3.768903915431242*^9, 
   3.7689039197578783`*^9}, {3.768904091492632*^9, 3.7689041150608983`*^9}, {
   3.7689041650389643`*^9, 3.768904182034179*^9}, {3.768905401412935*^9, 
   3.7689054035910573`*^9}, {3.7689054852734146`*^9, 
   3.7689055132666073`*^9}, {3.76890561559*^9, 3.768905636101339*^9}, {
   3.7689984908949623`*^9, 3.768998492197207*^9}, {3.7689986706032896`*^9, 
   3.7689986707504272`*^9}, 3.76900051144162*^9, {3.769667292429305*^9, 
   3.76966732283525*^9}, {3.769667411801306*^9, 3.7696674128681464`*^9}, {
   3.7696674494975157`*^9, 3.7696674771269746`*^9}, {3.7696675279533386`*^9, 
   3.769667536844982*^9}, {3.7696675837476463`*^9, 3.769667587877054*^9}, {
   3.7697477473142405`*^9, 3.7697477641227903`*^9}, {3.769747797271249*^9, 
   3.7697478544453297`*^9}, {3.769748134123003*^9, 3.7697481445893335`*^9}, {
   3.7697482343182077`*^9, 3.769748238411008*^9}, {3.769748280697935*^9, 
   3.7697482912423325`*^9}, {3.7697490009661984`*^9, 
   3.7697490204772377`*^9}, {3.7697490770108285`*^9, 
   3.7697491081128883`*^9}, {3.7697492058243017`*^9, 3.769749224460558*^9}, {
   3.7697492789165*^9, 3.769749297896429*^9}, {3.7697493449166307`*^9, 
   3.7697493610846944`*^9}, 3.769750101598489*^9, {3.769752151792632*^9, 
   3.769752271978362*^9}, {3.7697524382321973`*^9, 3.7697524960300493`*^9}, {
   3.7697530394500003`*^9, 3.769753092035779*^9}, {3.769753178265218*^9, 
   3.7697532130028305`*^9}, {3.7697532703222885`*^9, 3.769753292540619*^9}, {
   3.7697533741636252`*^9, 3.769753436044987*^9}, {3.7697535132179327`*^9, 
   3.769753516665329*^9}, 3.7697535818502827`*^9, {3.769922030223013*^9, 
   3.769922053699747*^9}, {3.7699224451857543`*^9, 3.769922486638294*^9}, {
   3.7699254723034325`*^9, 3.769925473271984*^9}, {3.771660100115201*^9, 
   3.7716601062800055`*^9}, {3.77166053487606*^9, 3.7716606259878173`*^9}, {
   3.7716623761238966`*^9, 3.7716623779596643`*^9}, {3.7716678911254325`*^9, 
   3.7716679089924345`*^9}, {3.7716679454177*^9, 3.77166799233274*^9}, {
   3.7716695970190773`*^9, 3.771669600389398*^9}, {3.771677568982067*^9, 
   3.7716775766050835`*^9}, {3.7716782969564185`*^9, 3.771678360053693*^9}, {
   3.7716784267759666`*^9, 3.7716784284344177`*^9}, {3.7716784911055613`*^9, 
   3.771678522673049*^9}, {3.7716785548654757`*^9, 3.771678589214897*^9}, {
   3.7716796500115128`*^9, 3.7716796836316442`*^9}, {3.771743068876005*^9, 
   3.7717430689298563`*^9}, {3.77174466019594*^9, 3.7717446622579923`*^9}, {
   3.771755638956787*^9, 3.7717556494710464`*^9}, {3.7717557338724613`*^9, 
   3.7717558208535852`*^9}, {3.7717564613961935`*^9, 3.771756483394667*^9}, {
   3.7717565588132677`*^9, 3.7717565847653637`*^9}, {3.771758180176942*^9, 
   3.7717581952406173`*^9}, {3.7719282620047493`*^9, 3.771928274281084*^9}, {
   3.773053676650999*^9, 3.773053690522129*^9}, 3.773063978148549*^9, {
   3.7731234898213634`*^9, 3.7731235282751245`*^9}, {3.775375371997332*^9, 
   3.7753753755161343`*^9}, {3.775381879597662*^9, 3.7753820307799625`*^9}, {
   3.7753822258368473`*^9, 3.775382269230371*^9}, {3.775382400406457*^9, 
   3.7753824182754817`*^9}, 3.775382551223713*^9, {3.77597032999426*^9, 
   3.775970330447278*^9}, {3.7759705888399467`*^9, 3.775970721027199*^9}, {
   3.7759710485869637`*^9, 3.7759710887198963`*^9}, {3.775971474224698*^9, 
   3.7759714748964148`*^9}, {3.775971532707755*^9, 3.7759715330955353`*^9}, {
   3.7759721163234186`*^9, 3.7759721173075643`*^9}, {3.7759738730554285`*^9, 
   3.7759740309008923`*^9}, {3.7759748008302064`*^9, 3.775974913086027*^9}, {
   3.7759750283600225`*^9, 3.775975032209963*^9}, {3.7759751833425517`*^9, 
   3.7759751865228715`*^9}, {3.7759754025482993`*^9, 3.77597544571861*^9}, {
   3.7759755157361407`*^9, 3.7759756273651576`*^9}, {3.7759757606940885`*^9, 
   3.775975784107974*^9}, {3.775976434150741*^9, 3.775976467643176*^9}, {
   3.7759765378057933`*^9, 3.775976600400424*^9}, {3.7759767817857*^9, 
   3.775976802977689*^9}, {3.77597691101481*^9, 3.7759769237682476`*^9}, {
   3.775977046928296*^9, 3.7759770513506327`*^9}, {3.775977139852575*^9, 
   3.7759772599952807`*^9}, {3.7759773025624247`*^9, 3.775977342687679*^9}, {
   3.775977809838889*^9, 3.775977812310458*^9}, {3.775978173456747*^9, 
   3.775978182960619*^9}, {3.7759783529285316`*^9, 3.7759783732318764`*^9}, {
   3.7759784908419094`*^9, 3.7759785383017845`*^9}, {3.7759787050729647`*^9, 
   3.7759787148939123`*^9}, {3.775978815087892*^9, 3.77597881521286*^9}, {
   3.775978887670947*^9, 3.7759789094696665`*^9}, {3.7759789669034915`*^9, 
   3.775978966965975*^9}, {3.77597905925445*^9, 3.77597905939504*^9}, {
   3.77597931651031*^9, 3.7759793438810096`*^9}, {3.775979393248663*^9, 
   3.775979396861303*^9}, {3.775979493900787*^9, 3.775979498870141*^9}, {
   3.7759795704519544`*^9, 3.7759795719515963`*^9}, {3.775980367498499*^9, 
   3.775980373688101*^9}, {3.7759804334722986`*^9, 3.7759804394118643`*^9}, {
   3.775980470034383*^9, 3.7759804759416084`*^9}, {3.7759805213187113`*^9, 
   3.7759805265232625`*^9}, {3.775980596710368*^9, 3.775980597866354*^9}, {
   3.775980685440336*^9, 3.775980701194945*^9}, {3.775980801032648*^9, 
   3.7759808040813193`*^9}, {3.775980906504019*^9, 3.775980943761853*^9}, {
   3.7759810222523394`*^9, 3.775981029988222*^9}, {3.775981071593402*^9, 
   3.775981137893276*^9}, {3.7759812064539804`*^9, 3.7759812173457317`*^9}, {
   3.775981267186038*^9, 3.7759812889275665`*^9}, {3.775981367822196*^9, 
   3.7759813933659244`*^9}, {3.7759814908037863`*^9, 3.775981512309603*^9}, {
   3.775982191035874*^9, 3.775982270888726*^9}, {3.775982659747901*^9, 
   3.775982715980893*^9}, {3.775983088714069*^9, 3.7759831014937725`*^9}, {
   3.775983479476821*^9, 3.775983494015912*^9}, {3.775984157083788*^9, 
   3.775984189105794*^9}, {3.775987638218315*^9, 3.775987669492136*^9}, {
   3.7759877882950287`*^9, 3.7759878103737164`*^9}, {3.7759879407630053`*^9, 
   3.77598794732751*^9}, {3.7759884426335487`*^9, 3.7759884433833733`*^9}, {
   3.7759903836128483`*^9, 3.7759903891335106`*^9}, {3.775990536786618*^9, 
   3.775990537630173*^9}, {3.775991052511698*^9, 3.77599109547548*^9}, {
   3.776056992233425*^9, 3.776057069303294*^9}, {3.776057153335003*^9, 
   3.7760571823878765`*^9}, {3.7760572182036057`*^9, 
   3.7760573256045346`*^9}, {3.77605742420984*^9, 3.7760574270080004`*^9}, {
   3.7760575890959277`*^9, 3.7760576223432865`*^9}, {3.776057657480855*^9, 
   3.776057745252927*^9}, {3.7760577990605288`*^9, 3.7760578380112743`*^9}, {
   3.7760604287191863`*^9, 3.77606046598678*^9}, {3.7760619884688883`*^9, 
   3.776062072334055*^9}, {3.7760627885494223`*^9, 3.7760627981098127`*^9}, {
   3.7760750179446545`*^9, 3.776075020666136*^9}, {3.7764888645709724`*^9, 
   3.7764889098753557`*^9}, {3.776489328125409*^9, 3.7764893391100535`*^9}, {
   3.77649131423363*^9, 3.7764913192681317`*^9}, {3.7764916880966997`*^9, 
   3.776491723375167*^9}, {3.7764926384497523`*^9, 3.7764927740143375`*^9}, {
   3.7764928183674555`*^9, 3.7764928867245255`*^9}, {3.7764945679353523`*^9, 
   3.7764946137514715`*^9}, {3.776495453736725*^9, 3.776495503977549*^9}, 
   3.7764955944029465`*^9, {3.776496911278183*^9, 3.7764969331721306`*^9}, 
   3.7764973570621305`*^9, {3.7764983447840176`*^9, 3.7764984575630236`*^9}, 
   3.7764985889090443`*^9, {3.776499585795329*^9, 3.776499585982813*^9}, {
   3.7764996323471537`*^9, 3.7764996341553574`*^9}, {3.7765011925631084`*^9, 
   3.776501230502634*^9}, 3.776501264702818*^9, {3.7765046444826655`*^9, 
   3.7765046472113724`*^9}, {3.776507174468521*^9, 3.7765072183103795`*^9}, 
   3.7765080755665674`*^9, {3.7782235757323546`*^9, 3.778223577241416*^9}, {
   3.7789220404263115`*^9, 3.7789220630006003`*^9}, 3.7789221044667997`*^9, {
   3.7789221359072857`*^9, 3.7789221586896644`*^9}, {3.7789237311543007`*^9, 
   3.7789237591190524`*^9}, {3.793018120756835*^9, 3.793018123576969*^9}, {
   3.7930181900905676`*^9, 3.7930181940923815`*^9}, 3.793035980039872*^9, {
   3.793106335043481*^9, 3.7931063531114197`*^9}, {3.7931164191303134`*^9, 
   3.7931164223439703`*^9}, {3.7967322254312787`*^9, 
   3.7967322355513597`*^9}, {3.850815071901292*^9, 3.850815145662879*^9}, {
   3.850815197881313*^9, 3.8508152428672905`*^9}, {3.8508157635682344`*^9, 
   3.850815764572797*^9}, 3.8508158040356255`*^9, {3.8508159263986874`*^9, 
   3.850815999633526*^9}, {3.8508163057829022`*^9, 3.850816437935964*^9}, {
   3.8508165313410544`*^9, 3.8508165578528976`*^9}, {3.8508172704911513`*^9, 
   3.8508173648959455`*^9}, {3.8508174125181413`*^9, 3.850817448754005*^9}, {
   3.850817524639171*^9, 3.850817542477711*^9}, {3.8508178137828074`*^9, 
   3.850817909907736*^9}, {3.850817951898738*^9, 3.850817977069121*^9}, {
   3.850818028669967*^9, 3.850818051351202*^9}, {3.8508181159191933`*^9, 
   3.8508182065049405`*^9}, {3.8508182806895823`*^9, 3.850818289336316*^9}, {
   3.8508183258070726`*^9, 3.8508183278359127`*^9}, {3.8508183612051325`*^9, 
   3.850818518286129*^9}, 3.8508187239545207`*^9, {3.8508191343984995`*^9, 
   3.8508191719869356`*^9}, {3.850819203089984*^9, 3.8508192378455715`*^9}, {
   3.850819374412201*^9, 3.8508194645888433`*^9}, {3.8508195601210756`*^9, 
   3.8508195638604155`*^9}, {3.850819624672181*^9, 3.8508196262779903`*^9}, {
   3.850820859240729*^9, 3.8508208774604807`*^9}, {3.8508209194455457`*^9, 
   3.8508209194960556`*^9}, {3.8508209926938763`*^9, 
   3.8508210759473886`*^9}, {3.8508212992217264`*^9, 3.850821351212199*^9}, {
   3.8508213849875965`*^9, 3.850821385270567*^9}, {3.8508214317950125`*^9, 
   3.850821431826255*^9}, {3.850821766102844*^9, 3.850821766322113*^9}, {
   3.850821869018364*^9, 3.8508218695507617`*^9}, {3.851066448608245*^9, 
   3.851066571604802*^9}, {3.8510677122401686`*^9, 3.8510677202160645`*^9}, {
   3.8510677602121325`*^9, 3.8510677603168793`*^9}, {3.851068299298009*^9, 
   3.8510683006971684`*^9}, {3.851068361487043*^9, 3.8510683615503273`*^9}, {
   3.8510684160078335`*^9, 3.8510684183915997`*^9}, {3.851244497790783*^9, 
   3.851244498786951*^9}, {3.851244626091014*^9, 3.851244714202984*^9}, {
   3.851245150163892*^9, 3.8512451920731745`*^9}, {3.8512452716592216`*^9, 
   3.851245310134405*^9}, {3.851245398444007*^9, 3.8512454339756737`*^9}, {
   3.8512454742038546`*^9, 3.851245487566362*^9}, {3.851245575998826*^9, 
   3.851245587367607*^9}, {3.851245638407413*^9, 3.8512456473975353`*^9}, {
   3.8512457116661315`*^9, 3.8512457514701896`*^9}, {3.8512458350424633`*^9, 
   3.8512458355652323`*^9}, {3.8512460437177954`*^9, 
   3.8512460526177845`*^9}, {3.851246833264872*^9, 3.851246839328143*^9}, 
   3.8515073074169846`*^9, {3.8515843192092533`*^9, 3.8515844129961185`*^9}, {
   3.851585337198927*^9, 3.851585360372138*^9}, {3.851585431525842*^9, 
   3.8515854316039305`*^9}, {3.8515854820832176`*^9, 
   3.8515855703664465`*^9}, {3.8515930943493557`*^9, 3.851593116326378*^9}, {
   3.8515989505738935`*^9, 3.8515990154321346`*^9}, {3.8515995803717666`*^9, 
   3.8515996267197533`*^9}, {3.8515996713801394`*^9, 
   3.8515996800113115`*^9}, {3.8515997363257847`*^9, 3.85159999931383*^9}, {
   3.851600033455225*^9, 3.851600134416837*^9}, {3.8516010606418095`*^9, 
   3.8516010688388968`*^9}, 3.8516011500463095`*^9, 3.851601215675002*^9, 
   3.851601279457867*^9, {3.8516013097126813`*^9, 3.851601317392064*^9}, {
   3.8516013588555727`*^9, 3.8516013713631744`*^9}, {3.8516014666488047`*^9, 
   3.851601478681609*^9}, {3.8516025452004075`*^9, 3.851602548415313*^9}, {
   3.851602820176403*^9, 3.8516028465755615`*^9}, {3.8516033373950195`*^9, 
   3.8516034345210996`*^9}, {3.851621545072527*^9, 3.851621548374962*^9}, {
   3.8516779381472816`*^9, 3.8516779864021745`*^9}, {3.8516780826477985`*^9, 
   3.851678083654154*^9}, {3.8516781334958196`*^9, 3.851678146322188*^9}, {
   3.851678232375604*^9, 3.851678237254529*^9}, 3.8516782689105024`*^9, {
   3.851678465799469*^9, 3.851678503397095*^9}, {3.8516785920857687`*^9, 
   3.8516785930712414`*^9}, {3.8516786286088343`*^9, 
   3.8516786354899387`*^9}, {3.8516786883465385`*^9, 3.85167869810627*^9}, {
   3.851678748116455*^9, 3.8516787543592625`*^9}, {3.851678811164028*^9, 
   3.8516788220481887`*^9}, {3.8517717832289643`*^9, 3.851771813727523*^9}, {
   3.8520192743399525`*^9, 3.852019379160453*^9}, {3.8520194170292535`*^9, 
   3.8520194213815265`*^9}, {3.852019457415291*^9, 3.8520194574756126`*^9}, {
   3.852019504114106*^9, 3.8520195463216925`*^9}, {3.852370973631966*^9, 
   3.8523710001138687`*^9}, 3.8523726445015216`*^9, {3.8523727353964796`*^9, 
   3.8523727484400077`*^9}, {3.852372791898356*^9, 3.8523728532164497`*^9}, {
   3.8523728971737595`*^9, 3.852372899772915*^9}, {3.8523729319196367`*^9, 
   3.8523729414218884`*^9}, {3.8523729718712206`*^9, 
   3.8523730143618307`*^9}, {3.8526358241261435`*^9, 
   3.8526358330001802`*^9}, {3.8526395447297506`*^9, 3.852639548220919*^9}, {
   3.8630862493517284`*^9, 3.8630862719769983`*^9}, {3.8630881882553988`*^9, 
   3.863088208072644*^9}, {3.8630894702658124`*^9, 3.8630894722184815`*^9}, {
   3.86351768537838*^9, 3.863517735920988*^9}, 3.894355433126083*^9, {
   3.89435619291395*^9, 3.894356213612858*^9}, {3.89435624432856*^9, 
   3.894356294931017*^9}, {3.8943563432035513`*^9, 3.894356354866317*^9}, {
   3.89435640842599*^9, 3.8943564154093237`*^9}, {3.894356453901175*^9, 
   3.8943564585416317`*^9}, {3.894356492234269*^9, 3.894356505102729*^9}, {
   3.894356575445203*^9, 3.894356599431712*^9}, {3.894356718083803*^9, 
   3.894356725280818*^9}, {3.894356793769631*^9, 3.894356815522719*^9}, {
   3.894356902844515*^9, 3.894356938880728*^9}, {3.894356986675679*^9, 
   3.894356994042242*^9}, {3.894358383139464*^9, 3.894358386837929*^9}, {
   3.894360858693782*^9, 3.89436086237257*^9}, {3.894428874233198*^9, 
   3.8944288757796087`*^9}, 3.894429267987933*^9, 3.894598675247448*^9, {
   3.8949628393715878`*^9, 3.8949628985267677`*^9}, {3.8949631164846992`*^9, 
   3.894963116853416*^9}, {3.894963405460121*^9, 3.894963407901166*^9}, {
   3.8949637647530193`*^9, 3.8949637891672297`*^9}, {3.8949638302535458`*^9, 
   3.894963843007197*^9}, 3.8949640691256*^9, {3.89496450365071*^9, 
   3.894964513788651*^9}, {3.894964861542099*^9, 3.894964861691476*^9}, {
   3.8949651462950363`*^9, 3.894965156337188*^9}, 3.894965201134613*^9, {
   3.894965437876664*^9, 3.8949654509984922`*^9}, {3.8949658758313932`*^9, 
   3.8949658783391933`*^9}, {3.894965908476426*^9, 3.894965959668703*^9}, 
   3.89496622668543*^9, {3.894966504565908*^9, 3.8949665050682087`*^9}, {
   3.89496690009731*^9, 3.894966902087474*^9}, 3.894966963649662*^9, 
   3.894967089325943*^9, {3.8967586153018847`*^9, 3.896758618793507*^9}, {
   3.8985229570221663`*^9, 3.89852295756607*^9}, {3.898523009221813*^9, 
   3.898523031804574*^9}, {3.8985868831652193`*^9, 3.898586912982183*^9}, {
   3.898586980307013*^9, 3.898586981896694*^9}, {3.898588083010705*^9, 
   3.898588138147753*^9}, {3.8985882509066477`*^9, 3.898588257861258*^9}, {
   3.898588386465019*^9, 3.8985883874519997`*^9}, 3.898588872783299*^9, {
   3.8986827652733583`*^9, 3.8986827782734623`*^9}, {3.898683960479742*^9, 
   3.898683986130227*^9}, {3.898684016247035*^9, 3.8986840262438383`*^9}, {
   3.898684430172763*^9, 3.898684432084651*^9}, 3.898743696792676*^9, {
   3.899303067800688*^9, 3.89930309155694*^9}, {3.899352061472444*^9, 
   3.899352065052074*^9}, {3.899356170106751*^9, 3.899356178568878*^9}, 
   3.8993569505762873`*^9, 3.8993570244247417`*^9, 3.899357063106043*^9, {
   3.899373003061851*^9, 3.899373026396669*^9}, 3.8997827844361267`*^9, {
   3.899960365906108*^9, 3.899960369470643*^9}, {3.899962621559903*^9, 
   3.89996262176197*^9}, {3.8999626683090353`*^9, 3.899962686187715*^9}, 
   3.8999627425339108`*^9, 3.89996277529149*^9, {3.899962807852868*^9, 
   3.8999629038119297`*^9}, {3.8999629978385363`*^9, 3.899963015598456*^9}, {
   3.899963604945134*^9, 3.899963651581974*^9}, {3.899963684059066*^9, 
   3.899963686279986*^9}, {3.899963723129971*^9, 3.899963769800002*^9}, {
   3.8999639660207567`*^9, 3.89996400059144*^9}, {3.899973724022591*^9, 
   3.8999737654518347`*^9}, {3.899974797126192*^9, 3.8999747979234343`*^9}, {
   3.899974869890026*^9, 3.899974956335977*^9}, {3.899975006579522*^9, 
   3.8999751132076178`*^9}, {3.899975345275909*^9, 3.899975393513893*^9}, {
   3.89997548073106*^9, 3.8999755780410643`*^9}, {3.899975649987844*^9, 
   3.899975651374611*^9}, {3.8999763250871687`*^9, 3.8999763274121532`*^9}, {
   3.8999763843652277`*^9, 3.899976500145768*^9}, {3.899976539598111*^9, 
   3.899976574297187*^9}, {3.899976615650041*^9, 3.899976623469557*^9}, {
   3.8999767156333437`*^9, 3.899976743837624*^9}, 3.899976796201906*^9, 
   3.899976829566496*^9, 3.899976862164646*^9, {3.899976893541089*^9, 
   3.899976914672516*^9}, {3.899977013048127*^9, 3.899977017521236*^9}, {
   3.899977057436561*^9, 3.89997712363671*^9}, {3.8999771593323507`*^9, 
   3.899977162907105*^9}, {3.899977216942017*^9, 3.8999772686521587`*^9}, {
   3.899977486820218*^9, 3.899977511157488*^9}, {3.899977561789509*^9, 
   3.899977569406034*^9}, {3.899977702475119*^9, 3.8999777186701813`*^9}, {
   3.8999787511992064`*^9, 3.899978772512678*^9}, {3.900037497713372*^9, 
   3.90003753897268*^9}, {3.900037599397575*^9, 3.9000376304605618`*^9}, {
   3.900037660944107*^9, 3.900037665982645*^9}, 3.900037700905188*^9, {
   3.900037755099834*^9, 3.900037766479187*^9}, {3.900037821405175*^9, 
   3.9000378555444403`*^9}, {3.900042640776866*^9, 3.900042663205771*^9}, 
   3.900042702296258*^9, {3.900042756110458*^9, 3.900042798203248*^9}, 
   3.900042895306079*^9, 3.900042979375983*^9, {3.900043295927347*^9, 
   3.9000433236368723`*^9}, {3.900043358314171*^9, 3.900043372037479*^9}, {
   3.900043494141584*^9, 3.9000435310112267`*^9}, {3.9000435831595907`*^9, 
   3.90004358874264*^9}, {3.900043625221874*^9, 3.9000436269378967`*^9}, {
   3.900043730930073*^9, 3.9000437314174833`*^9}, {3.9000444962936983`*^9, 
   3.90004449832516*^9}, {3.90004467048943*^9, 3.9000447058915157`*^9}, {
   3.90004474428573*^9, 3.9000447739367647`*^9}, {3.90004555525051*^9, 
   3.900045568025834*^9}, {3.9000457592042723`*^9, 3.900045760665436*^9}, 
   3.900047575521502*^9, {3.900055187298457*^9, 3.9000551935043507`*^9}, {
   3.90005572283914*^9, 3.900055722970948*^9}, {3.900055808611637*^9, 
   3.900055816505714*^9}, {3.900056471198662*^9, 3.90005656891049*^9}, {
   3.900056945424526*^9, 3.900056946685458*^9}, {3.9001345010838757`*^9, 
   3.900134502919634*^9}, {3.900136881681295*^9, 3.900136899156187*^9}, {
   3.9001418724222727`*^9, 3.900141883093334*^9}, {3.9001419358835917`*^9, 
   3.9001419360465727`*^9}, {3.900143970595347*^9, 3.900143990794758*^9}, {
   3.90014402851604*^9, 3.900144050993382*^9}, {3.900144467389*^9, 
   3.9001444675251827`*^9}, {3.900146887460425*^9, 3.9001468911185923`*^9}, {
   3.9001469741990623`*^9, 3.9001469787205143`*^9}, {3.900147600590076*^9, 
   3.900147602019487*^9}, 3.900240606931382*^9, {3.900241357575179*^9, 
   3.900241358721141*^9}, 3.900241648291318*^9, 3.9002418677311373`*^9, 
   3.900243248652205*^9, {3.9003875757109947`*^9, 3.900387599303091*^9}, {
   3.9003936128584757`*^9, 3.900393688614607*^9}, {3.900393775780641*^9, 
   3.90039378369591*^9}, {3.900393826260364*^9, 3.900393845043585*^9}, {
   3.900393901442449*^9, 3.9003939047246523`*^9}, {3.9003940039677563`*^9, 
   3.9003940079923353`*^9}, {3.900394075474998*^9, 3.900394081042849*^9}, {
   3.900394116951405*^9, 3.900394139898546*^9}, {3.900394242531845*^9, 
   3.900394243876444*^9}, {3.900394318613411*^9, 3.900394321516686*^9}, {
   3.900472567669314*^9, 3.900472571040184*^9}, {3.900474401137856*^9, 
   3.900474449429181*^9}, {3.900729273920268*^9, 3.9007292758943987`*^9}, {
   3.9007293250891523`*^9, 3.900729326085888*^9}, {3.90078265122336*^9, 
   3.900782656361507*^9}, 3.900782695169765*^9, {3.9009895265695963`*^9, 
   3.90098954727001*^9}, 3.902827196907474*^9},
 CellLabel->"In[51]:=",ExpressionUUID->"625c85b7-68f4-4271-a435-0b60f8618dde"]
}, Closed]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{
   RowBox[{
    RowBox[{"solverHelper2", " ", "-", " ", 
     RowBox[{"Expand", " ", "to", " ", 
      RowBox[{"view", ".", " ", "N"}], " ", "agents"}]}], ";", " ", 
    RowBox[{
    "A", " ", "version", " ", "of", " ", "SolveModel", " ", "that", " ", 
     "takes", " ", "child", " ", "costs", " ", "as", " ", "given", " ", "and",
      " ", "infers", " ", "population", " ", "growth", " ", 
     RowBox[{"rates", ".", " ", "Initial"}], " ", "distribution", " ", "of", 
     " ", 
     RowBox[{"ktilde", "'"}], "s"}]}], ",", " ", 
   RowBox[{
    RowBox[{"n", "'"}], "s", " ", "and", " ", "ctildes", " ", 
    RowBox[{"given", ".", " ", "Pie"}], " ", "Changes"}], ",", " ", 
   RowBox[{
    RowBox[{
    "omegas", " ", "can", " ", "be", " ", "anhything", " ", "between", " ", 
     "0", " ", "and", " ", 
     RowBox[{"1", " ", "--"}], " ", "if", " ", "\[Omega]"}], "=", 
    RowBox[{
    "0", " ", "then", " ", "Blanchard", " ", "type", " ", "selfishness", " ", 
     RowBox[{"mechanism", ".", " ", "For"}], " ", 
     RowBox[{"Mutation", ".", " ", "remember"}], " ", "that", " ", "since", 
     " ", "we", " ", "are", " ", "pinning", " ", "down", " ", "k0", " ", 
     "and", " ", "n0"}]}], ",", " ", 
   RowBox[{
   "we", " ", "no", " ", "longer", " ", "are", " ", "able", " ", "to", " ", 
    "assume", " ", "that", " ", "k", " ", "is", " ", "on", " ", "a", " ", 
    "saddle", " ", 
    RowBox[{"path", ".", " ", "As"}], " ", "such"}], ",", " ", 
   RowBox[{
    RowBox[{
    "we", " ", "cannot", " ", "use", " ", "relN0", " ", "to", " ", "solve", 
     " ", "for", " ", "dynasty", " ", "shares"}], " ", "-", " ", 
    RowBox[{
    "instead", " ", "we", " ", "need", " ", "to", " ", "use", " ", "our", " ",
      "guess", " ", "of", " ", "c0"}]}]}], "*)"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.},
 CellChangeTimes->{{3.5450253019140635`*^9, 3.545025304915063*^9}, {
   3.5450324742890635`*^9, 3.5450324819140635`*^9}, {3.724479346029998*^9, 
   3.7244794610184035`*^9}, {3.7244795438463507`*^9, 3.724479554254569*^9}, {
   3.7260565353620577`*^9, 3.7260565430614977`*^9}, 3.7260578532684374`*^9, 
   3.726579461512018*^9, {3.726579559728636*^9, 3.726579586301156*^9}, {
   3.7265804157025948`*^9, 3.726580472134823*^9}, {3.726675052388584*^9, 
   3.7266750541206837`*^9}, {3.726736336745963*^9, 3.72673634385637*^9}, {
   3.7267458479639735`*^9, 3.7267458612117314`*^9}, {3.7270949226440563`*^9, 
   3.7270949246821723`*^9}, 3.727096924615328*^9, 3.7271009968402452`*^9, {
   3.7271015671358647`*^9, 3.7271015677228985`*^9}, {3.7610437803591704`*^9, 
   3.7610437849279823`*^9}, {3.7619207454984493`*^9, 3.7619207476240177`*^9}, 
   3.7730639713097205`*^9, {3.776491683018301*^9, 3.7764917078746634`*^9}, {
   3.8515995582518587`*^9, 3.8515995628012094`*^9}, {3.851768684051326*^9, 
   3.8517686869411545`*^9}, {3.8520219625179977`*^9, 
   3.8520219654061565`*^9}, {3.8523736907830973`*^9, 3.852373695966022*^9}, {
   3.8945986752469788`*^9, 3.8945987151205263`*^9}, {3.899959950199046*^9, 
   3.899959967359538*^9}, {3.9000475981904078`*^9, 3.900047604999505*^9}, {
   3.900049112549391*^9, 3.900049113041253*^9}, {3.900130556338998*^9, 
   3.9001305577133913`*^9}, 3.900136994911936*^9, 3.900151643849455*^9, {
   3.900749749928524*^9, 3.900749770656938*^9}, {3.900750174304823*^9, 
   3.9007501779795732`*^9}, {3.901252466090413*^9, 3.901252510310149*^9}},
 CellLabel->"In[52]:=",ExpressionUUID->"a873ae3b-807f-45c9-a6c5-bd83d286f954"],

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{
   RowBox[{"Expand", " ", "to", " ", 
    RowBox[{"View", ":", " ", 
     RowBox[{
     "Returns", " ", "the", " ", "error", " ", "in", " ", "the", " ", "final",
       " ", "FOC", " ", "given", " ", "the", " ", "guess", " ", "of", " ", 
      "relative", " ", "initial", " ", "consumption", " ", "in", " ", "the", 
      " ", "first", " ", 
      RowBox[{"position", ".", " ", "In"}], " ", "the", " ", "second", " ", 
      "position"}]}]}], ",", " ", 
   RowBox[{
   "returns", " ", "the", " ", "solutions", " ", "given", " ", "the", " ", 
    "guess", "  ", "of", " ", "relative", " ", "initial", " ", 
    RowBox[{"consumption", ".", "\[IndentingNewLine]", "Need"}], " ", "to", 
    " ", "Adjust", " ", "until", " ", "error", " ", "is", " ", 
    RowBox[{"zero", "."}]}]}], "*)"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.},
 CellChangeTimes->{{3.7265804668015175`*^9, 3.726580472134823*^9}, 
   3.894598675247232*^9, 3.900151643849813*^9},
 CellLabel->"In[53]:=",ExpressionUUID->"acf46a6d-6b6b-42a1-8ba3-3c56f710484f"],

Cell[BoxData[
 RowBox[{
  RowBox[{
   RowBox[{"solverHelper2", "[", 
    RowBox[{"C0tildeVector_List", ",", "parameterVector_"}], "]"}], ":=", 
   "\[IndentingNewLine]", 
   RowBox[{"Module", "[", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{
       RowBox[{"pVectorAll", "=", "parameterVector"}], ",", "pVector", ",", 
       RowBox[{"C0tildeVec", "=", "C0tildeVector"}], ",", 
       "\[IndentingNewLine]", "\[Alpha]", ",", "\[Beta]A", ",", "\[Beta]B", 
       ",", "Pie", ",", "time", ",", "\[Xi]", ",", "\[Nu]", ",", 
       "\[IndentingNewLine]", "\[IndentingNewLine]", "wtilde", ",", "r", ",", 
       "Cetilde", ",", "citilde", ",", "gDee", ",", "eN", ",", "kiitilde", 
       ",", "Dee", ",", "afunc", ",", "ass", ",", "Deefuncx", ",", 
       "\[IndentingNewLine]", "\[IndentingNewLine]", "eqs", ",", "eqs1", ",", 
       "eqs2", ",", "eqs3", ",", "eqs4", ",", "eqs5", ",", 
       "\[IndentingNewLine]", "\[IndentingNewLine]", "eq", ",", "eq1", ",", 
       "eq2", ",", "eq3", ",", "eq4", ",", "eq5", ",", "\[IndentingNewLine]", 
       "\[IndentingNewLine]", "varRelcB0", ",", "answerAllNi", ",", 
       "answerktilde", ",", "answerAllci", ",", "answerAllKi", ",", 
       "answerAllsi", ",", "answerW", ",", "points", ",", "answerAllYi", ",", 
       "answerY", ",", "answera", ",", "relbeta", ",", "eNdata", ",", "greN", 
       ",", "answerD", ",", "answersavingsrate", ",", "answerK", ",", 
       "answery", ",", "Piess", ",", "Piefunc", ",", "relonealphabeta", ",", 
       "\[IndentingNewLine]", "\[IndentingNewLine]", "a", ",", " ", 
       "\[Delta]", ",", "N0", ",", "grDee", ",", "gNss", ",", "geN", ",", 
       "ktildess", ",", "ansSS", ",", "answerTemp", ",", "answerkitilde", ",",
        " ", "answerctilde", ",", "  ", "answerN", ",", "answerp", ",", 
       "answerR", ",", "answerCtildeAg", ",", "vars", ",", "answer", ",", " ",
        "\[Beta]vec", ",", "propNvec", ",", "sorted\[Beta]Location", ",", 
       "nTypes", ",", " ", "acc", ",", "temp", ",", "temp2", ",", "temp3", 
       ",", "tempNp", ",", "helper", ",", "helper2", ",", "helper3", ",", 
       "ci", ",", "Kii", ",", "Nii", ",", "sii", ",", "cij", ",", "Kij", ",", 
       "Nij", ",", "pct", ",", "answerCQuantiles", ",", "answerKQuantiles", 
       ",", "answerNQuantiles", ",", "indexpct", ",", "answerKii", ",", 
       "answerKi", ",", "answerSharesSelectedYears", ",", 
       "answerSocietalBeta", ",", "inityear", ",", "currentyear", ",", 
       "cyperiod", ",", "initPoint", ",", "\[Omega]", ",", "answerFert", ",", 
       "rN", ",", "CetildeN", ",", "wtildeN", ",", "afuncN", ",", "wap", ",", 
       "helpersums", ",", "kitildeN", ",", "citildex", ",", "ansDif", ",", 
       "answergN", ",", "aData", ",", "N0vec", ",", "K0vec", ",", "tempkagg", 
       ",", "ctildeNew", ",", "i"}], "}"}], ",", "\[IndentingNewLine]", 
     "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
     "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"pVector", "=", 
       RowBox[{"pVectorAll", "[", 
        RowBox[{"[", 
         RowBox[{"All", ",", "2"}], "]"}], "]"}]}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{"N0vec", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "1", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", 
       RowBox[{
       "Intial", " ", "population", " ", "levels", " ", "by", " ", "type", 
        " ", "in", " ", "period", " ", "zero"}], "*)"}], 
      "\[IndentingNewLine]", 
      RowBox[{
       SubscriptBox["N", "0"], "=", 
       RowBox[{"Total", "[", "N0vec", "]"}]}], ";", "         ", 
      RowBox[{"(*", 
       RowBox[{"Total", " ", "initial", " ", "population"}], "*)"}], 
      "\[IndentingNewLine]", 
      RowBox[{"K0vec", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "2", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", 
       RowBox[{
       "Intial", " ", "Capital", " ", "levels", " ", "by", " ", "type", " ", 
        "in", " ", "period", " ", "zero"}], "*)"}], "\[IndentingNewLine]", 
      RowBox[{
       SubscriptBox["ktilde", "0"], "=", 
       RowBox[{"Total", "[", "K0vec", "]"}]}], ";", "      ", 
      RowBox[{"(*", 
       RowBox[{"Initial", " ", "capital", " ", "stock"}], "*)"}], 
      "\[IndentingNewLine]", 
      RowBox[{"\[Beta]vec", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "3", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", 
       RowBox[{"Reads", " ", "in", " ", "the", " ", "betas"}], "*)"}], 
      "\[IndentingNewLine]", 
      RowBox[{"\[Delta]", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "4", "]"}], "]"}]}], ";", "     ", 
      RowBox[{"(*", 
       RowBox[{"Total", " ", 
        RowBox[{"Land", "/", "Capital"}]}], "*)"}], "\[IndentingNewLine]", 
      RowBox[{"aData", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "5", "]"}], "]"}]}], ";", 
      RowBox[{"(*", 
       RowBox[{"Child", " ", "cost", " ", "parameters"}], "*)"}], 
      "\[IndentingNewLine]", 
      RowBox[{"greN", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "6", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", 
       RowBox[{
       "long", " ", "run", " ", "growth", " ", "rate", " ", "of", " ", 
        "population"}], "*)"}], "\[IndentingNewLine]", 
      RowBox[{"Dee", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "7", "]"}], "]"}]}], ";", "  ", 
      RowBox[{"(*", 
       RowBox[{"Level", " ", "of", " ", "TFP"}], "*)"}], 
      "\[IndentingNewLine]", 
      RowBox[{"grDee", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "8", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", 
       RowBox[{
       "long", " ", "run", " ", "growth", " ", "rate", " ", "of", " ", 
        "productivity"}], "*)"}], "\[IndentingNewLine]", 
      RowBox[{"\[Nu]", " ", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "9", "]"}], "]"}]}], ";", "   ", 
      RowBox[{"(*", 
       RowBox[{
       "Land", " ", "Share", " ", "in", " ", "Production", " ", "Function"}], 
       "*)"}], "\[IndentingNewLine]", 
      RowBox[{"\[Alpha]", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "10", "]"}], "]"}]}], ";", "     ", 
      RowBox[{"(*", 
       RowBox[{"Preference", " ", "weight", " ", "on", " ", "consumption"}], 
       "*)"}], "\[IndentingNewLine]", 
      RowBox[{"Pie", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "11", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", 
       RowBox[{
       "Probability", " ", "of", " ", "death", " ", "of", " ", "adults"}], 
       "*)"}], "\[IndentingNewLine]", 
      RowBox[{"Piess", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "12", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", 
       RowBox[{
       "Probability", " ", "of", " ", "death", " ", "of", " ", "adults", " ", 
        "in", " ", "long", " ", "run"}], "*)"}], "\[IndentingNewLine]", 
      RowBox[{"\[Omega]", " ", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "13", "]"}], "]"}]}], ";", "    ", 
      RowBox[{"(*", 
       RowBox[{"Altruism", " ", "paramter"}], "*)"}], "\[IndentingNewLine]", 
      RowBox[{"time", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "14", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", " ", 
       RowBox[{"The", " ", "time", " ", "periods", " ", "under", " ", 
        RowBox[{"consideration", "."}]}], "*)"}], "\[IndentingNewLine]", 
      RowBox[{"acc", "=", 
       RowBox[{"pVector", "[", 
        RowBox[{"[", "15", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", "Accuracy", "*)"}], "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"If", "[", 
       RowBox[{
        RowBox[{
         RowBox[{"Length", "[", "pVector", "]"}], "\[Equal]", "16"}], ",", 
        "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"initPoint", "=", 
          RowBox[{"pVector", "[", 
           RowBox[{"[", "16", "]"}], "]"}]}], ";"}]}], " ", 
       RowBox[{"(*", 
        RowBox[{
        "Guess", " ", "to", " ", "solution", " ", "if", " ", "givemn"}], 
        "*)"}], "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"Piefunc", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"Piefunc", "[", "t", "]"}], "=", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"t", "\[LessEqual]", 
           RowBox[{
            RowBox[{"Length", "[", "Pie", "]"}], "-", "1"}]}], ",", 
          RowBox[{"Pie", "[", 
           RowBox[{"[", 
            RowBox[{"t", "+", "1"}], "]"}], "]"}], ",", "Piess"}], "]"}]}]}], 
      ";", " ", 
      RowBox[{"(*", 
       RowBox[{"Probability", " ", "of", " ", "survival", " ", "functino"}], 
       "*)"}], "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"sorted\[Beta]Location", "=", 
       RowBox[{"Reverse", "[", 
        RowBox[{"Ordering", "[", "\[Beta]vec", "]"}], "]"}]}], ";", " ", 
      RowBox[{"(*", 
       RowBox[{
       "Returns", " ", "the", " ", "location", " ", "of", " ", "the", " ", 
        "sorted", " ", "betas", " ", "from", " ", "largest", " ", "to", " ", 
        "smallest", " ", "in", " ", "pVector\[Beta]"}], "*)"}], 
      "\[IndentingNewLine]", 
      RowBox[{"nTypes", "=", 
       RowBox[{"Length", "[", "\[Beta]vec", "]"}]}], ";", "  ", 
      RowBox[{"(*", 
       RowBox[{"Number", " ", "of", " ", "different", " ", "types"}], "*)"}], 
      "\[IndentingNewLine]", 
      RowBox[{"For", "[", 
       RowBox[{
        RowBox[{"i", "=", "1"}], ",", 
        RowBox[{"i", "\[LessEqual]", "nTypes"}], ",", 
        RowBox[{"i", "++"}], ",", "\[IndentingNewLine]", 
        RowBox[{"(*", 
         RowBox[{
          RowBox[{"j", "=", 
           RowBox[{"sorted\[Beta]Location", "[", 
            RowBox[{"[", "i", "]"}], "]"}]}], ";"}], 
         RowBox[{"(*", 
          RowBox[{
          "Find", " ", "the", " ", "location", " ", "of", " ", "the", " ", 
           "sorted", " ", "beta"}], "*)"}], "*)"}], "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"j", "=", "i"}], ";", "\[IndentingNewLine]", 
         RowBox[{
          SubscriptBox["\[Beta]", "i"], "=", 
          RowBox[{"\[Beta]vec", "[", 
           RowBox[{"[", "j", "]"}], "]"}]}], ";", " ", 
         RowBox[{"(*", 
          RowBox[{
          "Assigns", " ", "beta", " ", "in", " ", "the", " ", "right", " ", 
           "order"}], "*)"}], "\[IndentingNewLine]", 
         RowBox[{
          SubscriptBox["ci0tilde", 
           RowBox[{"i", ",", "0"}]], "=", 
          RowBox[{"SetPrecision", "[", 
           RowBox[{
            RowBox[{"C0tildeVec", "[", 
             RowBox[{"[", "j", "]"}], "]"}], ",", "acc"}], "]"}]}], ";", " ", 
         "\[IndentingNewLine]", 
         RowBox[{
          SubscriptBox["kitilde", 
           RowBox[{"i", ",", "0"}]], "=", 
          RowBox[{"SetPrecision", "[", 
           RowBox[{
            RowBox[{"K0vec", "[", 
             RowBox[{"[", "j", "]"}], "]"}], ",", "acc"}], "]"}]}], ";", 
         "\[IndentingNewLine]", 
         RowBox[{
          SubscriptBox["Ni", 
           RowBox[{"i", ",", "0"}]], "=", 
          RowBox[{"SetPrecision", "[", 
           RowBox[{
            RowBox[{"N0vec", "[", 
             RowBox[{"[", "j", "]"}], "]"}], ",", "acc"}], "]"}]}], ";", " ", 
         RowBox[{"(*", 
          RowBox[{
          "Assigns", " ", "beta", " ", "in", " ", "the", " ", "right", " ", 
           "order"}], "*)"}], "\[IndentingNewLine]", 
         RowBox[{
          SubscriptBox["relN0", "i"], "=", 
          RowBox[{"SetPrecision", "[", 
           RowBox[{
            FractionBox[
             SubscriptBox["Ni", 
              RowBox[{"i", ",", "0"}]], 
             SubscriptBox["Ni", 
              RowBox[{"1", ",", "0"}]]], ",", "acc"}], "]"}]}], ";", " ", 
         RowBox[{"(*", 
          RowBox[{
          "Calculate", " ", "the", " ", "proportions", " ", "of", " ", 
           "people", " ", "in", " ", "each", " ", "type", " ", "relative", 
           " ", "to", " ", "the", " ", "highest", " ", "beta", " ", "type"}], 
          "*)"}], "\[IndentingNewLine]", 
         RowBox[{
          SubscriptBox["relctilde0", "i"], "=", 
          RowBox[{"SetPrecision", "[", 
           RowBox[{
            FractionBox[
             RowBox[{"SetPrecision", "[", 
              RowBox[{
               SubscriptBox["ci0tilde", 
                RowBox[{"i", ",", "0"}]], ",", "acc"}], "]"}], 
             RowBox[{"SetPrecision", "[", 
              RowBox[{
               SubscriptBox["ci0tilde", 
                RowBox[{"1", ",", "0"}]], ",", "acc"}], "]"}]], ",", "acc"}], 
           "]"}]}], ";"}]}], "\[IndentingNewLine]", 
       RowBox[{"(*", " ", 
        RowBox[{
        "Given", " ", "the", " ", "above", " ", "calculate", " ", "the", " ", 
         "relative", " ", "proportions", " ", "of", " ", "consumption", " ", 
         "of", " ", "each", " ", "type", " ", "relative", " ", "to", " ", 
         "the", " ", "highest", " ", "beta", " ", "type"}], "*)"}], 
       "\[IndentingNewLine]", "\[IndentingNewLine]", "]"}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"gDee", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"gDee", "[", "t", "]"}], "=", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"t", "\[LessEqual]", 
           RowBox[{
            RowBox[{"Length", "[", "Dee", "]"}], "-", "2"}]}], ",", 
          FractionBox[
           RowBox[{"Dee", "[", 
            RowBox[{"[", 
             RowBox[{"t", "+", "2"}], "]"}], "]"}], 
           RowBox[{"Dee", "[", 
            RowBox[{"[", 
             RowBox[{"t", "+", "1"}], "]"}], "]"}]], ",", "grDee"}], 
         "]"}]}]}], ";", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"Deefuncx", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"Deefuncx", "[", "t", "]"}], "=", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"t", "\[Equal]", "0"}], ",", 
          RowBox[{"Dee", "[", 
           RowBox[{"[", "1", "]"}], "]"}], ",", 
          RowBox[{
           RowBox[{"Deefuncx", "[", 
            RowBox[{"t", "-", "1"}], "]"}], "*", 
           RowBox[{"gDee", "[", "t", "]"}]}]}], "]"}]}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"Clear", "[", 
       RowBox[{"gNss", ",", "ktildess", ",", "ass"}], "]"}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{"gNss", "=", "greN"}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"ansSS", "=", 
       RowBox[{"FindRoot", "[", 
        RowBox[{
         RowBox[{"{", 
          RowBox[{
           RowBox[{"gNss", "==", 
            RowBox[{
             RowBox[{"(", 
              RowBox[{
               RowBox[{
                RowBox[{"-", "ass"}], " ", "Piess", " ", 
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{"-", "1"}], "+", "\[Alpha]"}], ")"}], " ", 
                RowBox[{"(", 
                 RowBox[{"1", "+", 
                  RowBox[{"Piess", " ", 
                   SubscriptBox["\[Beta]", "1"], " ", 
                   RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "\[Omega]"}], ")"}]}], "-", 
                  RowBox[{
                   SubscriptBox["\[Beta]", "1"], " ", "\[Omega]"}]}], ")"}]}],
                "+", 
               RowBox[{"ktildess", " ", 
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{"-", "1"}], "+", "\[Delta]"}], ")"}], " ", 
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{"-", "1"}], "+", "\[Alpha]", "+", 
                  RowBox[{
                   SubscriptBox["\[Beta]", "1"], " ", 
                   RowBox[{"(", 
                    RowBox[{"Piess", "+", "\[Omega]", "-", 
                    RowBox[{"Piess", " ", "\[Omega]"}]}], ")"}]}]}], ")"}]}], 
               "+", 
               RowBox[{
                SuperscriptBox["ktildess", "\[Nu]"], " ", 
                RowBox[{"(", 
                 RowBox[{"1", "-", 
                  RowBox[{"Piess", " ", 
                   SubscriptBox["\[Beta]", "1"]}], "+", 
                  RowBox[{
                   RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "Piess"}], ")"}], " ", 
                   SubscriptBox["\[Beta]", "1"], " ", "\[Omega]"}], "+", 
                  RowBox[{"\[Alpha]", " ", 
                   RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", 
                    RowBox[{
                    SubscriptBox["\[Beta]", "1"], " ", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "\[Nu]"}], ")"}], " ", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "Piess"}], "+", 
                    RowBox[{
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"-", "1"}], "+", "Piess"}], ")"}], " ", 
                    "\[Omega]"}]}], ")"}]}]}], ")"}]}]}], ")"}]}]}], ")"}], 
             "/", 
             RowBox[{"(", 
              RowBox[{"ass", "+", 
               RowBox[{"ass", " ", "Piess", " ", 
                SubscriptBox["\[Beta]", "1"], " ", 
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{"-", "1"}], "+", "\[Omega]"}], ")"}]}], "-", 
               RowBox[{"ass", " ", 
                SubscriptBox["\[Beta]", "1"], " ", "\[Omega]"}], "-", 
               RowBox[{
                SuperscriptBox["grDee", 
                 FractionBox["1", 
                  RowBox[{"1", "-", "\[Nu]"}]]], " ", "ktildess", " ", 
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{"-", "1"}], "+", "\[Alpha]", "+", 
                  RowBox[{
                   SubscriptBox["\[Beta]", "1"], " ", 
                   RowBox[{"(", 
                    RowBox[{"Piess", "+", "\[Omega]", "-", 
                    RowBox[{"Piess", " ", "\[Omega]"}]}], ")"}]}]}], 
                 ")"}]}]}], ")"}]}]}], ",", 
           RowBox[{"ktildess", "==", 
            SuperscriptBox[
             RowBox[{"(", 
              FractionBox[
               RowBox[{
                RowBox[{
                 SuperscriptBox["grDee", 
                  FractionBox["1", 
                   RowBox[{"1", "-", "\[Nu]"}]]], " ", "gNss"}], "+", 
                RowBox[{
                 RowBox[{"(", 
                  RowBox[{
                   RowBox[{"Piess", " ", 
                    RowBox[{"(", 
                    RowBox[{"1", "-", "\[Omega]"}], ")"}]}], "+", 
                   "\[Omega]"}], ")"}], " ", 
                 SubscriptBox["\[Beta]", "1"], " ", 
                 RowBox[{"(", 
                  RowBox[{
                   RowBox[{"-", "1"}], "+", "\[Delta]"}], ")"}]}]}], 
               RowBox[{
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{"Piess", " ", 
                   RowBox[{"(", 
                    RowBox[{"1", "-", "\[Omega]"}], ")"}]}], "+", 
                  "\[Omega]"}], ")"}], " ", 
                SubscriptBox["\[Beta]", "1"], " ", "\[Nu]"}]], ")"}], 
             FractionBox["1", 
              RowBox[{
               RowBox[{"-", "1"}], "+", "\[Nu]"}]]]}]}], "}"}], ",", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"{", 
            RowBox[{"ass", ",", "0.15"}], "}"}], ",", 
           RowBox[{"{", 
            RowBox[{"ktildess", ",", "0.06"}], "}"}]}], "}"}]}], "]"}]}], ";",
       "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"ass", "=", 
       RowBox[{"ass", "/.", "ansSS"}]}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"ktildess", "=", 
       RowBox[{"ktildess", "/.", "ansSS"}]}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"afunc", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"afunc", "[", "t", "]"}], "=", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"t", "\[LessEqual]", 
           RowBox[{
            RowBox[{"Length", "[", "aData", "]"}], "-", "1"}]}], ",", 
          RowBox[{"aData", "[", 
           RowBox[{"[", 
            RowBox[{"t", "+", "1"}], "]"}], "]"}], ",", "ass"}], "]"}]}]}], 
      ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"wtilde", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"wtilde", "[", "t", "]"}], "=", 
        RowBox[{
         RowBox[{"(", 
          RowBox[{"1", "-", "\[Nu]"}], ")"}], "*", 
         SuperscriptBox[
          RowBox[{"(", 
           RowBox[{"SetPrecision", "[", 
            RowBox[{
             SubscriptBox["ktilde", "t"], ",", "acc"}], "]"}], ")"}], 
          RowBox[{"SetPrecision", "[", 
           RowBox[{"\[Nu]", ",", "acc"}], "]"}]]}]}]}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"r", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"r", "[", "t", "]"}], "=", 
        RowBox[{"\[Nu]", "*", 
         SuperscriptBox[
          RowBox[{"(", 
           RowBox[{"SetPrecision", "[", 
            RowBox[{
             SubscriptBox["ktilde", "t"], ",", "acc"}], "]"}], ")"}], 
          RowBox[{"SetPrecision", "[", 
           RowBox[{
            RowBox[{"\[Nu]", "-", "1"}], ",", "acc"}], "]"}]]}]}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"Cetilde", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"Cetilde", "[", "t", "]"}], "=", 
        RowBox[{
         SuperscriptBox[
          RowBox[{"SetPrecision", "[", 
           RowBox[{
            SubscriptBox["ktilde", "t"], ",", "acc"}], "]"}], 
          RowBox[{"SetPrecision", "[", 
           RowBox[{"\[Nu]", ",", "acc"}], "]"}]], "-", 
         RowBox[{"(", 
          RowBox[{
           RowBox[{
            RowBox[{"SetPrecision", "[", 
             RowBox[{
              SubscriptBox["gN", 
               RowBox[{"1", "+", "t"}]], ",", "acc"}], "]"}], " ", 
            SuperscriptBox[
             RowBox[{"gDee", "[", 
              RowBox[{"1", "+", "t"}], "]"}], 
             FractionBox["1", 
              RowBox[{"1", "-", "\[Nu]"}]]], " ", 
            RowBox[{"SetPrecision", "[", 
             RowBox[{
              SubscriptBox["ktilde", 
               RowBox[{"1", "+", "t"}]], ",", "acc"}], "]"}]}], "-", 
           RowBox[{
            RowBox[{"(", 
             RowBox[{"1", "-", "\[Delta]"}], ")"}], 
            RowBox[{"SetPrecision", "[", " ", 
             RowBox[{
              SubscriptBox["ktilde", "t"], ",", "acc"}], "]"}]}]}], ")"}], 
         "-", 
         RowBox[{
          RowBox[{"afunc", "[", "t", "]"}], "*", " ", 
          RowBox[{"(", 
           RowBox[{
            RowBox[{"SetPrecision", "[", 
             RowBox[{
              SubscriptBox["gN", 
               RowBox[{"1", "+", "t"}]], ",", "acc"}], "]"}], "-", 
            RowBox[{"Piefunc", "[", "t", "]"}]}], " ", ")"}]}]}]}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"relonealphabeta", "[", 
        RowBox[{"t_", ",", "j_"}], "]"}], ":=", 
       RowBox[{
        RowBox[{"relonealphabeta", "[", 
         RowBox[{"t", ",", "j"}], "]"}], "=", 
        RowBox[{"SetPrecision", "[", 
         RowBox[{
          FractionBox[
           RowBox[{"1", "-", "\[Alpha]", "-", 
            RowBox[{
             RowBox[{"SetPrecision", "[", 
              RowBox[{
               SubscriptBox["\[Beta]", "j"], ",", "acc"}], "]"}], "*", 
             RowBox[{"(", 
              RowBox[{"\[Omega]", "+", 
               RowBox[{
                RowBox[{"(", 
                 RowBox[{"1", "-", "\[Omega]"}], ")"}], " ", 
                RowBox[{"Piefunc", "[", "t", "]"}]}]}], ")"}]}]}], 
           RowBox[{"1", "-", "\[Alpha]", "-", 
            RowBox[{
             RowBox[{"SetPrecision", "[", 
              RowBox[{
               SubscriptBox["\[Beta]", "1"], ",", "acc"}], "]"}], "*", 
             RowBox[{"(", 
              RowBox[{"\[Omega]", "+", 
               RowBox[{
                RowBox[{"(", 
                 RowBox[{"1", "-", "\[Omega]"}], ")"}], " ", 
                RowBox[{"Piefunc", "[", "t", "]"}]}]}], ")"}]}]}]], ",", 
          "acc"}], "]"}]}]}], ";", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"relbeta", "[", 
        RowBox[{"t_", ",", "j_"}], "]"}], ":=", 
       RowBox[{
        RowBox[{"relbeta", "[", 
         RowBox[{"t", ",", "j"}], "]"}], "=", 
        RowBox[{"SetPrecision", "[", 
         RowBox[{
          SuperscriptBox[
           RowBox[{"(", 
            RowBox[{"SetPrecision", "[", 
             RowBox[{
              FractionBox[
               SubscriptBox["\[Beta]", "j"], 
               SubscriptBox["\[Beta]", "1"]], ",", "acc"}], "]"}], ")"}], 
           "t"], ",", "acc"}], "]"}]}]}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"helper2", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"helper2", "[", "t", "]"}], "=", 
        RowBox[{"(", 
         RowBox[{"1", "+", 
          RowBox[{
           UnderoverscriptBox["\[Sum]", 
            RowBox[{"j", "=", "2"}], "nTypes"], 
           RowBox[{
            SubscriptBox["relctilde0", "j"], "*", 
            RowBox[{"relbeta", "[", 
             RowBox[{"t", ",", "j"}], "]"}]}]}]}], ")"}]}]}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"helper3", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"helper3", "[", "t", "]"}], "=", 
        RowBox[{"(", 
         RowBox[{"1", "+", 
          RowBox[{
           UnderoverscriptBox["\[Sum]", 
            RowBox[{"j", "=", "2"}], "nTypes"], 
           RowBox[{
            SubscriptBox["relctilde0", "j"], "*", 
            RowBox[{"relbeta", "[", 
             RowBox[{"t", ",", "j"}], "]"}], "*", 
            RowBox[{"relonealphabeta", "[", 
             RowBox[{
              RowBox[{"t", "+", "1"}], ",", "j"}], "]"}]}]}]}], ")"}]}]}], 
      ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{
       SubscriptBox["gN", 
        RowBox[{"time", "+", "1"}]], "=", "gNss"}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{
       SubscriptBox["ktilde", 
        RowBox[{"time", "+", "1"}]], "=", "ktildess"}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"eqs1", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{
         RowBox[{
          SubscriptBox["\[Beta]", "1"], 
          RowBox[{"(", 
           RowBox[{"\[Omega]", "+", 
            RowBox[{
             RowBox[{"(", 
              RowBox[{"1", "-", "\[Omega]"}], ")"}], " ", 
             RowBox[{"Piefunc", "[", 
              RowBox[{"t", "+", "1"}], "]"}]}]}], ")"}], 
          RowBox[{"(", 
           RowBox[{
            RowBox[{"(", 
             RowBox[{"1", "-", "\[Delta]"}], ")"}], "+", 
            RowBox[{"r", "[", 
             RowBox[{"t", "+", "1"}], "]"}]}], ")"}], 
          FractionBox[
           RowBox[{"helper2", "[", 
            RowBox[{"t", "+", "1"}], "]"}], 
           RowBox[{"helper2", "[", "t", "]"}]], 
          RowBox[{"Cetilde", "[", "t", "]"}]}], "-", 
         RowBox[{
          RowBox[{"Cetilde", "[", 
           RowBox[{"t", "+", "1"}], "]"}], "*", 
          SuperscriptBox[
           RowBox[{"gDee", "[", 
            RowBox[{"t", "+", "1"}], "]"}], 
           FractionBox["1", 
            RowBox[{"1", "-", "\[Nu]"}]]], 
          SubscriptBox["gN", 
           RowBox[{"t", "+", "1"}]]}]}], "\[Equal]", "0"}]}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"eqs2", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{
         RowBox[{"\[Alpha]", " ", 
          SubscriptBox["\[Beta]", "1"], 
          RowBox[{"(", 
           RowBox[{"\[Omega]", "+", 
            RowBox[{
             RowBox[{"(", 
              RowBox[{"1", "-", "\[Omega]"}], ")"}], " ", 
             RowBox[{"Piefunc", "[", 
              RowBox[{"t", "+", "1"}], "]"}]}]}], ")"}], 
          RowBox[{"(", 
           RowBox[{
            RowBox[{"wtilde", "[", 
             RowBox[{"1", "+", "t"}], "]"}], "+", 
            RowBox[{
             RowBox[{"Piefunc", "[", 
              RowBox[{"t", "+", "1"}], "]"}], "*", 
             RowBox[{"afunc", "[", 
              RowBox[{"t", "+", "1"}], "]"}]}]}], ")"}], "*", 
          RowBox[{"Cetilde", "[", "t", "]"}]}], "+", 
         RowBox[{
          RowBox[{"(", 
           RowBox[{"1", "-", "\[Alpha]", "-", 
            RowBox[{
             SubscriptBox["\[Beta]", "1"], 
             RowBox[{"(", 
              RowBox[{"\[Omega]", "+", 
               RowBox[{
                RowBox[{"(", 
                 RowBox[{"1", "-", "\[Omega]"}], ")"}], " ", 
                RowBox[{"Piefunc", "[", 
                 RowBox[{"t", "+", "1"}], "]"}]}]}], ")"}]}]}], ")"}], 
          FractionBox[
           RowBox[{"helper3", "[", "t", "]"}], 
           RowBox[{"helper2", "[", 
            RowBox[{"t", "+", "1"}], "]"}]], "*", 
          RowBox[{"Cetilde", "[", 
           RowBox[{"t", "+", "1"}], "]"}], "*", 
          RowBox[{"Cetilde", "[", "t", "]"}]}], "-", 
         RowBox[{"\[Alpha]", " ", 
          RowBox[{"Cetilde", "[", 
           RowBox[{"t", "+", "1"}], "]"}], 
          SubscriptBox["gN", 
           RowBox[{"t", "+", "1"}]], "*", 
          RowBox[{"afunc", "[", "t", "]"}], "*", 
          FractionBox[
           RowBox[{"helper2", "[", "t", "]"}], 
           RowBox[{"helper2", "[", 
            RowBox[{"t", "+", "1"}], "]"}]]}]}], "\[Equal]", "0"}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"If", "[", 
       RowBox[{
        RowBox[{
         RowBox[{"Length", "[", "pVector", "]"}], "\[Equal]", "16"}], ",", 
        "\[IndentingNewLine]", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"answerTemp", "=", 
          RowBox[{"FindRoot", "[", 
           RowBox[{
            RowBox[{"Join", "[", 
             RowBox[{
              RowBox[{"Table", "[", 
               RowBox[{
                RowBox[{"eqs2", "[", "t", "]"}], ",", 
                RowBox[{"{", 
                 RowBox[{"t", ",", "0", ",", 
                  RowBox[{"time", "-", "1"}]}], "}"}]}], "]"}], ",", 
              RowBox[{"Table", "[", 
               RowBox[{
                RowBox[{"eqs1", "[", "t", "]"}], ",", 
                RowBox[{"{", 
                 RowBox[{"t", ",", "0", ",", 
                  RowBox[{"time", "-", "1"}]}], "}"}]}], "]"}]}], "]"}], ",", 
            RowBox[{"Join", "[", 
             RowBox[{
              RowBox[{"Table", "[", 
               RowBox[{
                RowBox[{"{", 
                 RowBox[{
                  SubscriptBox["gN", "i"], ",", 
                  RowBox[{"(", 
                   RowBox[{
                    SubscriptBox["gN", "i"], "/.", "initPoint"}], ")"}]}], 
                 "}"}], ",", 
                RowBox[{"{", 
                 RowBox[{"i", ",", "1", ",", "time"}], "}"}]}], "]"}], ",", 
              RowBox[{"Table", "[", 
               RowBox[{
                RowBox[{"{", 
                 RowBox[{
                  SubscriptBox["ktilde", "i"], ",", 
                  RowBox[{"(", 
                   RowBox[{
                    SubscriptBox["ktilde", "i"], "/.", "initPoint"}], ")"}]}],
                  "}"}], ",", 
                RowBox[{"{", 
                 RowBox[{"i", ",", "1", ",", "time"}], "}"}]}], "]"}]}], 
             "]"}], ",", 
            RowBox[{"MaxIterations", "\[Rule]", "1000"}]}], "]"}]}], ";"}], 
        "\[IndentingNewLine]", "\[IndentingNewLine]", ",", 
        "\[IndentingNewLine]", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"answerTemp", "=", 
          RowBox[{"FindRoot", "[", 
           RowBox[{
            RowBox[{"Join", "[", 
             RowBox[{
              RowBox[{"Table", "[", 
               RowBox[{
                RowBox[{"eqs2", "[", "t", "]"}], ",", 
                RowBox[{"{", 
                 RowBox[{"t", ",", "0", ",", 
                  RowBox[{"time", "-", "1"}]}], "}"}]}], "]"}], ",", 
              RowBox[{"Table", "[", 
               RowBox[{
                RowBox[{"eqs1", "[", "t", "]"}], ",", 
                RowBox[{"{", 
                 RowBox[{"t", ",", "0", ",", 
                  RowBox[{"time", "-", "1"}]}], "}"}]}], "]"}]}], "]"}], ",", 
            RowBox[{"Join", "[", 
             RowBox[{
              RowBox[{"Table", "[", 
               RowBox[{
                RowBox[{"{", 
                 RowBox[{
                  SubscriptBox["gN", "i"], ",", "0.7"}], " ", "}"}], ",", 
                RowBox[{"{", 
                 RowBox[{"i", ",", "1", ",", "time"}], "}"}]}], "]"}], ",", 
              RowBox[{"Table", "[", 
               RowBox[{
                RowBox[{"{", 
                 RowBox[{
                  SubscriptBox["ktilde", "i"], ",", "0.07"}], "}"}], ",", 
                RowBox[{"{", 
                 RowBox[{"i", ",", "1", ",", "time"}], "}"}]}], "]"}]}], 
             "]"}], ",", 
            RowBox[{"MaxIterations", "\[Rule]", "1000"}]}], "]"}]}], ";"}]}], 
       "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"answerR", "=", 
       RowBox[{
        RowBox[{"Table", "[", 
         RowBox[{
          RowBox[{
           SubscriptBox["R", "t"], "\[Rule]", 
           RowBox[{"1", "-", "\[Delta]", "+", 
            RowBox[{"r", "[", "t", "]"}]}]}], ",", 
          RowBox[{"{", 
           RowBox[{"t", ",", "0", ",", "time"}], "}"}]}], "]"}], "/.", 
        "answerTemp"}]}], ";", "\[IndentingNewLine]", 
      RowBox[{"answergN", "=", 
       RowBox[{"Table", "[", 
        RowBox[{
         RowBox[{
          SubscriptBox["gN", "t"], "\[Rule]", 
          RowBox[{"(", 
           RowBox[{
            SubscriptBox["gN", "t"], "/.", "answerTemp"}], ")"}]}], ",", 
         RowBox[{"{", 
          RowBox[{"t", ",", "0", ",", "time"}], "}"}]}], "]"}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"eN", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"eN", "[", "t", "]"}], "=", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"t", "==", "0"}], ",", 
          SubscriptBox["N", "0"], ",", 
          RowBox[{"If", "[", 
           RowBox[{
            RowBox[{"t", "\[LessEqual]", "time"}], ",", 
            RowBox[{
             RowBox[{"(", 
              RowBox[{
               SubscriptBox["gN", "t"], "/.", "answerTemp"}], ")"}], "*", 
             RowBox[{"eN", "[", 
              RowBox[{"t", "-", "1"}], "]"}]}], ",", 
            RowBox[{"gNss", "*", 
             RowBox[{"eN", "[", 
              RowBox[{"t", "-", "1"}], "]"}]}]}], "]"}]}], "]"}]}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"Nii", "[", 
        RowBox[{"i_", ",", "t_"}], "]"}], ":=", 
       RowBox[{
        RowBox[{"Nii", "[", 
         RowBox[{"i", ",", "t"}], "]"}], "=", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"t", "==", "0"}], ",", 
          RowBox[{"N0vec", "[", 
           RowBox[{"[", "i", "]"}], "]"}], ",", 
          RowBox[{"If", "[", 
           RowBox[{
            RowBox[{"t", "\[LessEqual]", "time"}], ",", 
            RowBox[{
             FractionBox[
              RowBox[{
               SubscriptBox["relctilde0", "i"], "*", 
               RowBox[{"relbeta", "[", 
                RowBox[{
                 RowBox[{"t", "-", "1"}], ",", "i"}], "]"}], "*", 
               RowBox[{"relonealphabeta", "[", 
                RowBox[{"t", ",", "i"}], "]"}]}], 
              RowBox[{"helper3", "[", 
               RowBox[{"t", "-", "1"}], "]"}]], "*", 
             RowBox[{"eN", "[", "t", "]"}]}], ",", 
            RowBox[{"If", "[", 
             RowBox[{
              RowBox[{"i", "\[Equal]", "1"}], ",", 
              RowBox[{"eN", "[", "t", "]"}], ",", "0"}], "]"}]}], "]"}]}], 
         "]"}]}]}], ";", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"citilde", "[", 
        RowBox[{"i_", ",", "t_"}], "]"}], ":=", 
       RowBox[{
        RowBox[{"citilde", "[", 
         RowBox[{"i", ",", "t"}], "]"}], "=", 
        RowBox[{"SetPrecision", "[", 
         RowBox[{
          RowBox[{
           RowBox[{
            FractionBox[
             RowBox[{
              SubscriptBox["relctilde0", "i"], "*", 
              RowBox[{"relbeta", "[", 
               RowBox[{"t", ",", "i"}], "]"}]}], 
             RowBox[{"helper2", "[", "t", "]"}]], "*", 
            RowBox[{"Cetilde", "[", "t", "]"}]}], "/.", "answerTemp"}], ",", 
          "acc"}], "]"}]}]}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"(*", 
       RowBox[{
        RowBox[{
         RowBox[{"--", 
          RowBox[{"--", "Can"}]}], " ", "comment", " ", "out", " ", "the", 
         " ", "below", " ", "if", " ", "not", " ", "looking", " ", "at", " ", 
         RowBox[{
          RowBox[{"distributions", "--"}], "--"}]}], "-"}], "*)"}], 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"For", "[", 
       RowBox[{
        RowBox[{"i", "=", "1"}], ",", 
        RowBox[{"i", "\[LessEqual]", "nTypes"}], ",", 
        RowBox[{"i", "++"}], ",", "\[IndentingNewLine]", 
        "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"If", "[", 
          RowBox[{
           RowBox[{"i", "\[Equal]", "1"}], ",", 
           RowBox[{
            SubscriptBox["kitilde", 
             RowBox[{"i", ",", 
              RowBox[{"time", "+", "1"}]}]], "=", "ktildess"}], ",", 
           RowBox[{
            SubscriptBox["kitilde", 
             RowBox[{"i", ",", 
              RowBox[{"time", "+", "1"}]}]], "=", "0"}]}], "]"}], ";"}]}], 
       "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"eqs3", "[", 
        RowBox[{"i_", ",", "t_"}], "]"}], ":=", 
       RowBox[{
        SubscriptBox["kitilde", 
         RowBox[{"i", ",", "t"}]], "==", 
        RowBox[{"SetPrecision", "[", 
         RowBox[{
          RowBox[{
           RowBox[{
            FractionBox["1", 
             RowBox[{"(", 
              RowBox[{"1", "-", "\[Delta]", "+", 
               RowBox[{"r", "[", "t", "]"}]}], ")"}]], 
            RowBox[{"(", 
             RowBox[{
              RowBox[{"citilde", "[", 
               RowBox[{"i", ",", "t"}], "]"}], "-", 
              RowBox[{
               RowBox[{"(", 
                RowBox[{
                 RowBox[{"wtilde", "[", "t", "]"}], "+", 
                 RowBox[{
                  RowBox[{"afunc", "[", "t", "]"}], "*", 
                  RowBox[{"Piefunc", "[", "t", "]"}]}]}], ")"}], "*", 
               FractionBox[
                RowBox[{"Nii", "[", 
                 RowBox[{"i", ",", "t"}], "]"}], 
                RowBox[{"eN", "[", "t", "]"}]]}], "+", 
              RowBox[{
               SubscriptBox["gN", 
                RowBox[{"t", "+", "1"}]], 
               RowBox[{"(", 
                RowBox[{
                 RowBox[{
                  RowBox[{"afunc", "[", "t", "]"}], "*", 
                  FractionBox[
                   RowBox[{"Nii", "[", 
                    RowBox[{"i", ",", 
                    RowBox[{"t", "+", "1"}]}], "]"}], 
                   RowBox[{"eN", "[", 
                    RowBox[{"t", "+", "1"}], "]"}]]}], "+", 
                 RowBox[{
                  SubscriptBox["kitilde", 
                   RowBox[{"i", ",", 
                    RowBox[{"t", "+", "1"}]}]], "*", 
                  SuperscriptBox[
                   RowBox[{"gDee", "[", 
                    RowBox[{"t", "+", "1"}], "]"}], 
                   FractionBox["1", 
                    RowBox[{"1", "-", "\[Nu]"}]]]}]}], ")"}]}]}], ")"}]}], "/.",
            "answerTemp"}], ",", "acc"}], "]"}]}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"answerkitilde", "=", 
       RowBox[{"Table", "[", 
        RowBox[{
         RowBox[{"Solve", "[", 
          RowBox[{
           RowBox[{"Table", "[", 
            RowBox[{
             RowBox[{"eqs3", "[", 
              RowBox[{"j", ",", "t"}], "]"}], ",", 
             RowBox[{"{", 
              RowBox[{"t", ",", "1", ",", "time"}], "}"}]}], "]"}], ",", 
           RowBox[{"Table", "[", 
            RowBox[{
             SubscriptBox["kitilde", 
              RowBox[{"j", ",", "t"}]], ",", 
             RowBox[{"{", 
              RowBox[{"t", ",", "1", ",", "time"}], "}"}]}], "]"}]}], "]"}], 
         ",", 
         RowBox[{"{", 
          RowBox[{"j", ",", "1", ",", "nTypes"}], "}"}]}], "]"}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"Do", "[", 
       RowBox[{
        RowBox[{
         RowBox[{
          SubscriptBox["tempk", 
           RowBox[{"j", ",", "0"}]], "=", 
          SubscriptBox["kitilde", 
           RowBox[{"j", ",", "0"}]]}], ";", 
         RowBox[{
          SubscriptBox["kitilde", 
           RowBox[{"j", ",", "0"}]], "=."}], ";"}], ",", 
        RowBox[{"{", 
         RowBox[{"j", ",", "1", ",", "nTypes"}], "}"}]}], "]"}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"kiitilde", "[", 
        RowBox[{"i_", ",", "t_"}], "]"}], ":=", 
       RowBox[{
        RowBox[{"kiitilde", "[", 
         RowBox[{"i", ",", "t"}], "]"}], "=", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"t", "==", "0"}], ",", 
          SubscriptBox["tempk", 
           RowBox[{"i", ",", "0"}]], ",", 
          RowBox[{"answerkitilde", "[", 
           RowBox[{"[", 
            RowBox[{"i", ",", "1", ",", "t", ",", "2"}], "]"}], "]"}]}], 
         "]"}]}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"CetildeN", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"CetildeN", "[", "t", "]"}], "=", 
        RowBox[{"SetPrecision", "[", 
         RowBox[{
          RowBox[{
           RowBox[{"Cetilde", "[", "t", "]"}], "/.", "answerTemp"}], ",", 
          "acc"}], "]"}]}]}], ";", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"rN", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"rN", "[", "t", "]"}], "=", 
        RowBox[{"SetPrecision", "[", 
         RowBox[{
          RowBox[{
           RowBox[{"r", "[", "t", "]"}], "/.", "answerTemp"}], ",", "acc"}], 
         "]"}]}]}], ";", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"wtildeN", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"wtildeN", "[", "t", "]"}], "=", 
        RowBox[{"SetPrecision", "[", 
         RowBox[{
          RowBox[{
           RowBox[{"wtilde", "[", "t", "]"}], "/.", "answerTemp"}], ",", 
          "acc"}], "]"}]}]}], ";", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"afuncN", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"afuncN", "[", "t", "]"}], "=", 
        RowBox[{"SetPrecision", "[", 
         RowBox[{
          RowBox[{
           RowBox[{"afunc", "[", "t", "]"}], "/.", "answerTemp"}], ",", 
          "acc"}], "]"}]}]}], ";", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"wap", "[", "t_", "]"}], ":=", 
       RowBox[{
        RowBox[{"wap", "[", "t", "]"}], "=", 
        RowBox[{"SetPrecision", "[", 
         RowBox[{
          RowBox[{"(", 
           FractionBox[
            RowBox[{
             RowBox[{"wtildeN", "[", "t", "]"}], "+", 
             RowBox[{
              RowBox[{"afuncN", "[", "t", "]"}], "*", 
              RowBox[{"Piefunc", "[", "t", "]"}]}]}], 
            RowBox[{"eN", "[", "t", "]"}]], ")"}], ",", "acc"}], "]"}]}]}], 
      ";", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"helpersums", "[", 
        RowBox[{"i_", ",", "t_"}], "]"}], ":=", 
       RowBox[{
        RowBox[{"helpersums", "[", 
         RowBox[{"i", ",", "t"}], "]"}], "=", 
        RowBox[{"SetPrecision", "[", 
         RowBox[{
          RowBox[{
           RowBox[{"(", 
            RowBox[{
             RowBox[{
              RowBox[{"wap", "[", "t", "]"}], "*", 
              RowBox[{"Nii", "[", 
               RowBox[{"i", ",", "t"}], "]"}]}], "-", 
             RowBox[{
              SubscriptBox["gN", 
               RowBox[{"t", "+", "1"}]], 
              RowBox[{"afuncN", "[", "t", "]"}], "*", 
              FractionBox[
               RowBox[{"Nii", "[", 
                RowBox[{"i", ",", 
                 RowBox[{"t", "+", "1"}]}], "]"}], 
               RowBox[{"eN", "[", 
                RowBox[{"t", "+", "1"}], "]"}]]}]}], ")"}], "/.", 
           "answerTemp"}], ",", "acc"}], "]"}]}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"citildex", "[", 
        RowBox[{"i_", ",", "t_"}], "]"}], ":=", 
       RowBox[{
        RowBox[{"citildex", "[", 
         RowBox[{"i", ",", "t"}], "]"}], "=", 
        RowBox[{
         RowBox[{"(", 
          RowBox[{
           RowBox[{
            RowBox[{"(", 
             RowBox[{"1", "-", "\[Delta]", "+", 
              RowBox[{"rN", "[", "t", "]"}]}], ")"}], 
            RowBox[{"kiitilde", "[", 
             RowBox[{"i", ",", "t"}], "]"}]}], "+", 
           RowBox[{"helpersums", "[", 
            RowBox[{"i", ",", "t"}], "]"}], "-", 
           RowBox[{
            SubscriptBox["gN", 
             RowBox[{"t", "+", "1"}]], 
            RowBox[{"kiitilde", "[", 
             RowBox[{"i", ",", 
              RowBox[{"t", "+", "1"}]}], "]"}], "*", 
            SuperscriptBox[
             RowBox[{"gDee", "[", 
              RowBox[{"t", "+", "1"}], "]"}], 
             FractionBox["1", 
              RowBox[{"1", "-", "\[Nu]"}]]]}]}], ")"}], "/.", 
         "answerTemp"}]}]}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"ansDif", "=", 
       RowBox[{"(", 
        RowBox[{"Table", "[", 
         RowBox[{
          RowBox[{
           FractionBox[
            RowBox[{"citildex", "[", 
             RowBox[{"i", ",", "0"}], "]"}], 
            RowBox[{"citilde", "[", 
             RowBox[{"i", ",", "0"}], "]"}]], "-", "1"}], ",", 
          RowBox[{"{", 
           RowBox[{"i", ",", "1", ",", "nTypes"}], "}"}]}], "]"}], ")"}]}], 
      ";", "\[IndentingNewLine]", 
      RowBox[{"ctildeNew", "=", 
       RowBox[{"(", 
        RowBox[{"Table", "[", 
         RowBox[{
          FractionBox[
           RowBox[{"citildex", "[", 
            RowBox[{"i", ",", "0"}], "]"}], 
           RowBox[{"CetildeN", "[", "0", "]"}]], ",", 
          RowBox[{"{", 
           RowBox[{"i", ",", "1", ",", "nTypes"}], "}"}]}], "]"}], ")"}]}], 
      ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"For", "[", 
       RowBox[{
        RowBox[{"i", "=", "1"}], ",", 
        RowBox[{"i", "\[LessEqual]", "nTypes"}], ",", 
        RowBox[{"i", "++"}], ",", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{
          SubscriptBox["Ni", 
           RowBox[{"i", ",", "0"}]], "=."}], ";"}]}], "\[IndentingNewLine]", 
       "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"tempkagg", "=", 
       SubscriptBox["ktilde", "0"]}], ";", "\[IndentingNewLine]", 
      RowBox[{
       SubscriptBox["ktilde", "0"], "=."}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"answer", "=", 
       RowBox[{"Table", "[", 
        RowBox[{
         RowBox[{"{", 
          RowBox[{
           RowBox[{"Table", "[", 
            RowBox[{
             RowBox[{
              SubscriptBox["Ni", 
               RowBox[{"j", ",", "t"}]], "\[Rule]", 
              RowBox[{"Nii", "[", 
               RowBox[{"j", ",", "t"}], "]"}]}], ",", 
             RowBox[{"{", 
              RowBox[{"j", ",", "1", ",", "nTypes"}], "}"}]}], "]"}], ",", 
           RowBox[{"Table", "[", 
            RowBox[{
             RowBox[{
              SubscriptBox["kitilde", 
               RowBox[{"j", ",", "t"}]], "\[Rule]", 
              RowBox[{"kiitilde", "[", 
               RowBox[{"j", ",", "t"}], "]"}]}], ",", 
             RowBox[{"{", 
              RowBox[{"j", ",", "1", ",", "nTypes"}], "}"}]}], "]"}], ",", 
           RowBox[{"Table", "[", 
            RowBox[{
             RowBox[{
              SubscriptBox["\[Beta]", 
               RowBox[{"j", ",", "t"}]], "\[Rule]", 
              SubscriptBox["\[Beta]", "j"]}], ",", 
             RowBox[{"{", 
              RowBox[{"j", ",", "1", ",", "nTypes"}], "}"}]}], "]"}], ",", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{
              SubscriptBox["R", "t"], "\[Rule]", 
              RowBox[{"(", 
               RowBox[{"1", "-", "\[Delta]", "+", 
                RowBox[{"r", "[", "t", "]"}]}], ")"}]}], "/.", "answerTemp"}],
             "}"}], ",", 
           RowBox[{"Table", "[", 
            RowBox[{
             RowBox[{
              SubscriptBox["ciitildeshare", 
               RowBox[{"j", ",", "t"}]], "\[Rule]", 
              FractionBox[
               RowBox[{"citilde", "[", 
                RowBox[{"j", ",", "t"}], "]"}], 
               RowBox[{"CetildeN", "[", "t", "]"}]]}], ",", 
             RowBox[{"{", 
              RowBox[{"j", ",", "1", ",", "nTypes"}], "}"}]}], "]"}], ",", 
           RowBox[{"{", 
            RowBox[{
             SubscriptBox["ktilde", "t"], "->", 
             RowBox[{"If", "[", 
              RowBox[{
               RowBox[{"t", ">", "0"}], ",", 
               RowBox[{"(", 
                RowBox[{
                 SubscriptBox["ktilde", "t"], "/.", "initPoint"}], ")"}], ",",
                "tempkagg"}], "]"}]}], "}"}], ",", 
           RowBox[{"{", 
            RowBox[{
             SubscriptBox["gN", "t"], "->", 
             RowBox[{"(", 
              RowBox[{
               SubscriptBox["gN", "t"], "/.", "initPoint"}], ")"}]}], "}"}]}],
           "}"}], ",", 
         RowBox[{"{", 
          RowBox[{"t", ",", "0", ",", "time"}], "}"}]}], "]"}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       SubscriptBox["ktilde", 
        RowBox[{"time", "+", "1"}]], "=."}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{
       SubscriptBox["N", "0"], "=."}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"For", "[", 
       RowBox[{
        RowBox[{"i", "=", "1"}], ",", 
        RowBox[{"i", "\[LessEqual]", "nTypes"}], ",", 
        RowBox[{"i", "++"}], ",", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{
          SubscriptBox["relN0", "i"], "=."}], ";", 
         RowBox[{
          SubscriptBox["\[Beta]", "i"], "=."}], ";", 
         RowBox[{
          SubscriptBox["relctilde0", "i"], "=."}], ";", 
         RowBox[{
          SubscriptBox["tempk", 
           RowBox[{"i", ",", "0"}]], "=."}], ";", 
         RowBox[{
          SubscriptBox["ci0tilde", 
           RowBox[{"i", ",", "0"}]], "=."}], ";"}]}], "\[IndentingNewLine]", 
       "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"Remove", "[", 
       RowBox[{
       "\[Alpha]", ",", "\[Beta]A", ",", "\[Beta]B", ",", "Pie", ",", "time", 
        ",", "\[Xi]", ",", "\[Nu]", ",", "\[IndentingNewLine]", 
        "\[IndentingNewLine]", "wtilde", ",", "r", ",", "Cetilde", ",", 
        "citilde", ",", "gDee", ",", "eN", ",", "kiitilde", ",", "Dee", ",", 
        "afunc", ",", "ass", ",", "Deefuncx", ",", "\[IndentingNewLine]", 
        "\[IndentingNewLine]", "eqs", ",", "eqs1", ",", "eqs2", ",", "eqs3", 
        ",", "eqs4", ",", "eqs5", ",", "\[IndentingNewLine]", 
        "\[IndentingNewLine]", "eq", ",", "eq1", ",", "eq2", ",", "eq3", ",", 
        "eq4", ",", "eq5", ",", "\[IndentingNewLine]", "\[IndentingNewLine]", 
        "varRelcB0", ",", "answerAllNi", ",", "answerktilde", ",", 
        "answerAllci", ",", "answerAllKi", ",", "answerAllsi", ",", "answerW",
         ",", "points", ",", "answerAllYi", ",", "answerY", ",", "answera", 
        ",", "relbeta", ",", "eNdata", ",", "greN", ",", "answerD", ",", 
        "answersavingsrate", ",", "answerK", ",", "answery", ",", "Piess", 
        ",", "Piefunc", ",", "relonealphabeta", ",", "\[IndentingNewLine]", 
        "\[IndentingNewLine]", "a", ",", " ", "\[Delta]", ",", "N0", ",", 
        "grDee", ",", "gNss", ",", "geN", ",", "ktildess", ",", "ansSS", ",", 
        "answerTemp", ",", "answerkitilde", ",", " ", "answerctilde", ",", 
        "  ", "answerN", ",", "answerp", ",", "answerR", ",", 
        "answerCtildeAg", ",", "vars", ",", " ", "\[Beta]vec", ",", 
        "propNvec", ",", "sorted\[Beta]Location", ",", "nTypes", ",", " ", 
        "acc", ",", "temp", ",", "temp2", ",", "temp3", ",", "tempNp", ",", 
        "helper", ",", "helper2", ",", "helper3", ",", "ci", ",", "Kii", ",", 
        "Nii", ",", "sii", ",", "cij", ",", "Kij", ",", "Nij", ",", "pct", 
        ",", "answerCQuantiles", ",", "answerKQuantiles", ",", 
        "answerNQuantiles", ",", "indexpct", ",", "answerKii", ",", 
        "answerKi", ",", "answerSharesSelectedYears", ",", 
        "answerSocietalBeta", ",", "inityear", ",", "currentyear", ",", 
        "cyperiod", ",", "initPoint", ",", "\[Omega]", ",", "answerFert", ",",
         "rN", ",", "CetildeN", ",", "wtildeN", ",", "afuncN", ",", "wap", 
        ",", "helpersums", ",", "kitildeN", ",", "citildex", ",", "answergN", 
        ",", "aData", ",", "N0vec", ",", "K0vec", ",", "tempkagg"}], "]"}], 
      ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"Return", "[", 
       RowBox[{"{", 
        RowBox[{"ansDif", ",", "answer", ",", "ctildeNew"}], "}"}], "]"}], 
      ";"}]}], "\[IndentingNewLine]", "]"}]}], ";"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.},
 CellChangeTimes->{{3.5450207567370634`*^9, 3.5450208126640635`*^9}, {
   3.5450213922850633`*^9, 3.545021455795063*^9}, {3.545021499609063*^9, 
   3.5450218859630632`*^9}, {3.545022337398063*^9, 3.545022363188063*^9}, {
   3.545022412753063*^9, 3.545022418451063*^9}, {3.545022458470063*^9, 
   3.545022462352063*^9}, {3.5450226095130634`*^9, 3.5450226831710634`*^9}, {
   3.5450227685530634`*^9, 3.545022796658063*^9}, {3.5450231576000633`*^9, 
   3.545023168904063*^9}, 3.545023328852063*^9, {3.5450235965720634`*^9, 
   3.545023615297063*^9}, 3.545023671896063*^9, 3.545025304915063*^9, {
   3.5452319574236*^9, 3.5452319810069494`*^9}, 3.5452320377051926`*^9, 
   3.5452324327457876`*^9, {3.546864863835182*^9, 3.546864899611182*^9}, 
   3.546864971144182*^9, {3.5468650373641825`*^9, 3.5468650609311824`*^9}, {
   3.546866633771182*^9, 3.5468666428381824`*^9}, {3.5468666796221824`*^9, 
   3.5468666868411827`*^9}, {3.5469414861762*^9, 3.5469414947692003`*^9}, 
   3.5471129347887774`*^9, {3.547113040450777*^9, 3.547113044292777*^9}, 
   3.5471181898287773`*^9, {3.547118969707777*^9, 3.547118976816777*^9}, {
   3.5471212301287775`*^9, 3.547121236237777*^9}, {3.547122382551777*^9, 
   3.547122390632777*^9}, {3.547127642744777*^9, 3.547127646376777*^9}, 
   3.5471281319847775`*^9, {3.547132407191777*^9, 3.547132413044777*^9}, {
   3.547133054195777*^9, 3.547133091931777*^9}, {3.547137681165777*^9, 
   3.5471376947607775`*^9}, 3.547137748890777*^9, {3.7244196368117094`*^9, 
   3.7244196690585537`*^9}, {3.7244199852736397`*^9, 3.72442000432973*^9}, 
   3.7244200575997767`*^9, {3.7244202517508817`*^9, 3.7244202524669228`*^9}, {
   3.7244202983375463`*^9, 3.7244202987585707`*^9}, {3.724422768788848*^9, 
   3.724422780798535*^9}, {3.724423196621319*^9, 3.7244232028736763`*^9}, {
   3.7244235236850257`*^9, 3.724423541280032*^9}, {3.724423603039564*^9, 
   3.724423603252577*^9}, {3.72442401819231*^9, 3.7244240721423955`*^9}, {
   3.724425328541513*^9, 3.72442533083232*^9}, {3.724479631636307*^9, 
   3.7244799070073957`*^9}, {3.7244800117084045`*^9, 3.724480165149476*^9}, {
   3.724480222995779*^9, 3.7244802376004047`*^9}, {3.724480279496479*^9, 
   3.724480318614748*^9}, {3.724480412895115*^9, 3.7244804508971825`*^9}, {
   3.7244804896596518`*^9, 3.7244805495495577`*^9}, {3.7244805910118313`*^9, 
   3.724480611153466*^9}, {3.724480755982724*^9, 3.7244807590715294`*^9}, {
   3.7244808686808624`*^9, 3.7244808847459183`*^9}, {3.724480916247033*^9, 
   3.7244809360271125`*^9}, {3.724480976263264*^9, 3.724480994060331*^9}, {
   3.7244810560325747`*^9, 3.724481194781082*^9}, {3.7244812255951834`*^9, 
   3.7244813092584925`*^9}, 3.724482642624999*^9, {3.724499784183713*^9, 
   3.7244997889219847`*^9}, {3.724499898947277*^9, 3.7244999067877254`*^9}, {
   3.724500319348323*^9, 3.72450032175146*^9}, {3.724580135076105*^9, 
   3.7245801734072976`*^9}, {3.7259716811998024`*^9, 
   3.7259717026180277`*^9}, {3.7259718195847178`*^9, 3.725971881274246*^9}, {
   3.7259720133337994`*^9, 3.7259720446285896`*^9}, {3.7259728538058715`*^9, 
   3.72597285464992*^9}, {3.725973025874714*^9, 3.725973038702447*^9}, {
   3.7259732006057076`*^9, 3.7259732305034175`*^9}, {3.7259734422325277`*^9, 
   3.725973443425596*^9}, {3.7259736826442785`*^9, 3.725973712402981*^9}, 
   3.725974082252135*^9, {3.725974168099045*^9, 3.725974171697251*^9}, {
   3.725974276747259*^9, 3.7259743103661823`*^9}, {3.725974496668838*^9, 
   3.725974498521944*^9}, 3.7259748561053967`*^9, {3.725975127455917*^9, 
   3.7259751291570144`*^9}, {3.725975210171648*^9, 3.7259752119847517`*^9}, {
   3.725975252817087*^9, 3.7259752548932056`*^9}, {3.7259752864320097`*^9, 
   3.725975289801203*^9}, 3.725975322131052*^9, 3.7259753545829077`*^9, {
   3.7259754974490795`*^9, 3.7259755232805567`*^9}, {3.725975563454855*^9, 
   3.725975588667297*^9}, 3.725975645441544*^9, 3.725975912794836*^9, {
   3.7259767322667065`*^9, 3.7259767777723093`*^9}, {3.7259768351155896`*^9, 
   3.72597683948584*^9}, {3.7259770115736823`*^9, 3.7259770124347315`*^9}, {
   3.725977843585271*^9, 3.7259778513217134`*^9}, 3.7259780865771694`*^9, {
   3.7259782106042633`*^9, 3.725978215138522*^9}, {3.725979573613223*^9, 
   3.725979578259488*^9}, {3.7259796622902946`*^9, 3.7259796627033186`*^9}, {
   3.7259797689373946`*^9, 3.7259797707714996`*^9}, {3.725982056292224*^9, 
   3.7259820623565702`*^9}, {3.7259823008802137`*^9, 3.725982304503421*^9}, 
   3.7259824300226*^9, {3.7259826255427833`*^9, 3.725982633688249*^9}, 
   3.726052533189146*^9, 3.72605654642269*^9, {3.726056584168849*^9, 
   3.726056584394862*^9}, {3.726056735840524*^9, 3.726056842057599*^9}, {
   3.7260569594213123`*^9, 3.726057006338996*^9}, {3.7260573801133747`*^9, 
   3.726057415089375*^9}, {3.7260576067103353`*^9, 3.726057621991209*^9}, {
   3.726057705075961*^9, 3.726057745505274*^9}, {3.7260577882457185`*^9, 
   3.726057788350724*^9}, 3.7260578532684374`*^9, {3.726058168965494*^9, 
   3.726058191954809*^9}, 3.7260584572559834`*^9, 3.7260585510203466`*^9, 
   3.7260586693901167`*^9, {3.7260587136876507`*^9, 3.7260587150287275`*^9}, 
   3.7260587885099297`*^9, {3.7260588803901854`*^9, 3.7260588874085865`*^9}, {
   3.726065395157809*^9, 3.7260654081495523`*^9}, 3.7260656730857053`*^9, 
   3.7261505320115995`*^9, {3.726150817149908*^9, 3.7261508223902082`*^9}, {
   3.7261508610924215`*^9, 3.726150863175541*^9}, {3.7261509226079397`*^9, 
   3.7261509268461823`*^9}, {3.7261510114810233`*^9, 3.7261510127760973`*^9}, 
   3.7261510472260675`*^9, 3.726151239068041*^9, {3.7262219221653395`*^9, 
   3.7262219459126973`*^9}, {3.726572778538774*^9, 3.72657296396938*^9}, {
   3.726575277551709*^9, 3.7265753263424997`*^9}, {3.72657919038251*^9, 
   3.726579245115641*^9}, {3.726579328005382*^9, 3.7265793459474087`*^9}, {
   3.7265794571257677`*^9, 3.7265794576507974`*^9}, {3.7265799193752065`*^9, 
   3.726580062607399*^9}, {3.7265802511051807`*^9, 3.726580253477316*^9}, {
   3.7265802907774496`*^9, 3.7265803011860447`*^9}, 3.726580332100813*^9, 
   3.726580472134823*^9, {3.7266782584229593`*^9, 3.7266782584839625`*^9}, {
   3.7266783520883164`*^9, 3.726678380217925*^9}, {3.7266784821867576`*^9, 
   3.7266784823207655`*^9}, {3.7266787722723494`*^9, 3.726678775699546*^9}, {
   3.7267378871756425`*^9, 3.7267378926259546`*^9}, {3.7267380012321663`*^9, 
   3.7267380443816347`*^9}, 3.7267383395445166`*^9, {3.7267386874814177`*^9, 
   3.726738687681429*^9}, {3.7267444538442345`*^9, 3.7267444738113766`*^9}, {
   3.7267445078853254`*^9, 3.7267445116465406`*^9}, {3.7267457891266084`*^9, 
   3.726745799611208*^9}, 3.726745894313625*^9, {3.7267459474936666`*^9, 
   3.7267459805325565`*^9}, {3.7267460135954475`*^9, 3.72674601364145*^9}, {
   3.7267460666484814`*^9, 3.7267461243247805`*^9}, {3.726746174803668*^9, 
   3.7267461757657228`*^9}, {3.726746250501998*^9, 3.7267462517090664`*^9}, {
   3.726746297312675*^9, 3.726746303088005*^9}, {3.7267463504067116`*^9, 
   3.726746381343481*^9}, {3.7267464139183445`*^9, 3.7267464155854397`*^9}, {
   3.7267464517585087`*^9, 3.7267464864564934`*^9}, 3.726819600791639*^9, {
   3.7268197192754154`*^9, 3.726819719388422*^9}, {3.7268198949364634`*^9, 
   3.72681997041078*^9}, {3.72682000135955*^9, 3.726820003057647*^9}, 
   3.72691757275277*^9, {3.727072630144998*^9, 3.7270726344392433`*^9}, {
   3.7270727025001364`*^9, 3.7270727041672316`*^9}, {3.7270728599741435`*^9, 
   3.727072918786507*^9}, {3.7270729491822457`*^9, 3.7270729909026318`*^9}, {
   3.727073513310512*^9, 3.727073542136161*^9}, {3.727074679458212*^9, 
   3.7270748814547653`*^9}, {3.727075074493807*^9, 3.7270750745778117`*^9}, {
   3.7270945860178022`*^9, 3.7270946626231833`*^9}, {3.7270947251547604`*^9, 
   3.727094761848859*^9}, {3.7270947954997835`*^9, 3.7270948121007333`*^9}, {
   3.7270948538851233`*^9, 3.7270949068631535`*^9}, {3.7270950033696733`*^9, 
   3.727095089821618*^9}, 3.727095232651553*^9, {3.7270952690986376`*^9, 
   3.727095271704787*^9}, {3.727095339118643*^9, 3.7270953396516733`*^9}, {
   3.727095959410121*^9, 3.7270959750520163`*^9}, {3.7270961075605946`*^9, 
   3.7270961520811415`*^9}, {3.727096333395512*^9, 3.7270963427230453`*^9}, {
   3.7270965519610133`*^9, 3.7270966642324347`*^9}, {3.7270967194025908`*^9, 
   3.7270967202946415`*^9}, 3.7270969294026017`*^9, {3.7271625649643507`*^9, 
   3.7271625827703686`*^9}, {3.727162660482814*^9, 3.7271626620939054`*^9}, {
   3.727163375511711*^9, 3.727163405971453*^9}, {3.7271634883771667`*^9, 
   3.7271634889061966`*^9}, {3.727163542124241*^9, 3.7271635923131113`*^9}, {
   3.7271643657323484`*^9, 3.727164372091712*^9}, {3.7271644136430883`*^9, 
   3.7271644879673395`*^9}, 3.727164521644266*^9, {3.727174777862838*^9, 
   3.7271747779968452`*^9}, {3.727359715845685*^9, 3.7273597179218035`*^9}, {
   3.7273599821989193`*^9, 3.7273599829359617`*^9}, 3.7273601710737224`*^9, 
   3.727362167636919*^9, {3.7274230101644087`*^9, 3.727423014298645*^9}, {
   3.727440638677702*^9, 3.7274406636271296`*^9}, 3.7274406964070044`*^9, 
   3.727440731352003*^9, {3.7274407796657662`*^9, 3.7274408067343144`*^9}, {
   3.727510206731958*^9, 3.72751020764401*^9}, 3.7275103904494658`*^9, {
   3.727527978340436*^9, 3.727528016145598*^9}, {3.727535745583697*^9, 
   3.7275357715461817`*^9}, {3.7275519585534515`*^9, 3.727551999871815*^9}, {
   3.727552131153324*^9, 3.7275522351042695`*^9}, {3.727552655918339*^9, 
   3.7275527050771503`*^9}, {3.727552771365942*^9, 3.727552784072669*^9}, {
   3.72755285070848*^9, 3.727552853584645*^9}, {3.727554772658409*^9, 
   3.7275547869542274`*^9}, 3.7610435364817405`*^9, {3.761043571231025*^9, 
   3.761043576165954*^9}, {3.7610436235881033`*^9, 3.7610436413449106`*^9}, {
   3.7610436729002457`*^9, 3.761043770878871*^9}, {3.7610438475156293`*^9, 
   3.7610438647290735`*^9}, {3.7610443741135235`*^9, 3.761044401042234*^9}, {
   3.7618924178069444`*^9, 3.761892420698386*^9}, {3.761892490182556*^9, 
   3.7618924929984612`*^9}, {3.761892545538104*^9, 3.761892574421073*^9}, {
   3.7618943501822863`*^9, 3.761894355806435*^9}, 3.7618944420269365`*^9, {
   3.761894590484105*^9, 3.7618945909553003`*^9}, {3.765706575514555*^9, 
   3.7657065967311754`*^9}, {3.7657069762490983`*^9, 3.765706998624098*^9}, {
   3.7657827346196156`*^9, 3.7657827346804476`*^9}, {3.7657827662081413`*^9, 
   3.765782776262255*^9}, {3.7657828291219053`*^9, 3.7657829030262814`*^9}, {
   3.765792704839733*^9, 3.765792713891528*^9}, {3.7657927941309633`*^9, 
   3.765792854728921*^9}, {3.7657928892486134`*^9, 3.7657929295766582`*^9}, {
   3.765792979001932*^9, 3.7657930204449406`*^9}, {3.7657931294908957`*^9, 
   3.7657931374256454`*^9}, {3.7657931713717318`*^9, 
   3.7657931859776144`*^9}, {3.7657939720100403`*^9, 
   3.7657941210305495`*^9}, {3.7657941752425876`*^9, 
   3.7657942749356403`*^9}, {3.7657943083572693`*^9, 3.765794317829939*^9}, 
   3.76579434791549*^9, {3.765794438973993*^9, 3.7657945077181673`*^9}, {
   3.765795044879264*^9, 3.7657950752816195`*^9}, 3.7657960529456987`*^9, 
   3.7657973933299627`*^9, 3.765866685458251*^9, {3.765866741061284*^9, 
   3.7658667423029637`*^9}, {3.7658675605738115`*^9, 3.765867632896985*^9}, {
   3.76586808998555*^9, 3.7658681576486278`*^9}, {3.765870398400258*^9, 
   3.765870398502982*^9}, {3.765870746165774*^9, 3.765870746206662*^9}, {
   3.765874668191653*^9, 3.765874668660451*^9}, {3.7658747061050673`*^9, 
   3.765874729806857*^9}, {3.765875398319106*^9, 3.765875401117617*^9}, {
   3.765876280541726*^9, 3.76587629695483*^9}, {3.7658763346779566`*^9, 
   3.765876338007025*^9}, {3.765876902981591*^9, 3.7658769609724207`*^9}, {
   3.7658770973194704`*^9, 3.7658770998766603`*^9}, {3.7658771811591372`*^9, 
   3.7658771850627003`*^9}, {3.7658772670901785`*^9, 
   3.7658772777028255`*^9}, {3.765877315014012*^9, 3.765877352872703*^9}, {
   3.765877425541308*^9, 3.765877426344161*^9}, {3.76587748017918*^9, 
   3.765877480255975*^9}, {3.7658775192685795`*^9, 3.765877539390752*^9}, {
   3.7658776192561045`*^9, 3.7658776350189996`*^9}, {3.765877844409308*^9, 
   3.7658778654739313`*^9}, {3.7658781572475634`*^9, 
   3.7658781732168517`*^9}, {3.7658785536763487`*^9, 
   3.7658785537621183`*^9}, {3.765878723204729*^9, 3.7658787278354254`*^9}, {
   3.765878821034837*^9, 3.765878824716008*^9}, {3.7658788602087345`*^9, 
   3.765878906257386*^9}, {3.7658789742188053`*^9, 3.765878977583871*^9}, {
   3.7658790137815223`*^9, 3.7658790168971925`*^9}, {3.7658799376814375`*^9, 
   3.7658799503366623`*^9}, {3.7658802835697455`*^9, 3.765880284330738*^9}, {
   3.7658803589922943`*^9, 3.7658803634055367`*^9}, {3.7658803953571463`*^9, 
   3.765880397842506*^9}, {3.765880428410843*^9, 3.7658804292576137`*^9}, {
   3.7658805076082697`*^9, 3.765880507758868*^9}, {3.7658805416603003`*^9, 
   3.765880560977695*^9}, {3.7658806147939253`*^9, 3.7658806186366596`*^9}, {
   3.765880689523216*^9, 3.7658807745617647`*^9}, {3.7658808085188737`*^9, 
   3.7658808113652554`*^9}, {3.7658808656150513`*^9, 
   3.7658808672945523`*^9}, {3.765884258963793*^9, 3.765884276245948*^9}, {
   3.7658848692984433`*^9, 3.765884895979295*^9}, {3.765884941039137*^9, 
   3.7658849467099524`*^9}, {3.7658850008335857`*^9, 
   3.7658850086916256`*^9}, {3.765885087197223*^9, 3.765885102892359*^9}, {
   3.767001403833307*^9, 3.767001408035447*^9}, 3.767072356048971*^9, {
   3.7670724191411943`*^9, 3.7670724494980583`*^9}, {3.768893865727254*^9, 
   3.768893891122732*^9}, {3.7688945439884176`*^9, 3.768894544740034*^9}, {
   3.7688945986450815`*^9, 3.7688946343340454`*^9}, {3.768894749355147*^9, 
   3.7688947878920264`*^9}, {3.7688949238677526`*^9, 3.768894954747985*^9}, {
   3.7689038263403683`*^9, 3.7689038282929125`*^9}, {3.768903915431242*^9, 
   3.7689039197578783`*^9}, {3.768904091492632*^9, 3.7689041150608983`*^9}, {
   3.7689041650389643`*^9, 3.768904182034179*^9}, {3.768905401412935*^9, 
   3.7689054035910573`*^9}, {3.7689054852734146`*^9, 
   3.7689055132666073`*^9}, {3.76890561559*^9, 3.768905636101339*^9}, {
   3.7689984908949623`*^9, 3.768998492197207*^9}, {3.7689986706032896`*^9, 
   3.7689986707504272`*^9}, 3.76900051144162*^9, {3.769667292429305*^9, 
   3.76966732283525*^9}, {3.769667411801306*^9, 3.7696674128681464`*^9}, {
   3.7696674494975157`*^9, 3.7696674771269746`*^9}, {3.7696675279533386`*^9, 
   3.769667536844982*^9}, {3.7696675837476463`*^9, 3.769667587877054*^9}, {
   3.7697477473142405`*^9, 3.7697477641227903`*^9}, {3.769747797271249*^9, 
   3.7697478544453297`*^9}, {3.769748134123003*^9, 3.7697481445893335`*^9}, {
   3.7697482343182077`*^9, 3.769748238411008*^9}, {3.769748280697935*^9, 
   3.7697482912423325`*^9}, {3.7697490009661984`*^9, 
   3.7697490204772377`*^9}, {3.7697490770108285`*^9, 
   3.7697491081128883`*^9}, {3.7697492058243017`*^9, 3.769749224460558*^9}, {
   3.7697492789165*^9, 3.769749297896429*^9}, {3.7697493449166307`*^9, 
   3.7697493610846944`*^9}, 3.769750101598489*^9, {3.769752151792632*^9, 
   3.769752271978362*^9}, {3.7697524382321973`*^9, 3.7697524960300493`*^9}, {
   3.7697530394500003`*^9, 3.769753092035779*^9}, {3.769753178265218*^9, 
   3.7697532130028305`*^9}, {3.7697532703222885`*^9, 3.769753292540619*^9}, {
   3.7697533741636252`*^9, 3.769753436044987*^9}, {3.7697535132179327`*^9, 
   3.769753516665329*^9}, 3.7697535818502827`*^9, {3.769922030223013*^9, 
   3.769922053699747*^9}, {3.7699224451857543`*^9, 3.769922486638294*^9}, {
   3.7699254723034325`*^9, 3.769925473271984*^9}, {3.771660100115201*^9, 
   3.7716601062800055`*^9}, {3.77166053487606*^9, 3.7716606259878173`*^9}, {
   3.7716623761238966`*^9, 3.7716623779596643`*^9}, {3.7716678911254325`*^9, 
   3.7716679089924345`*^9}, {3.7716679454177*^9, 3.77166799233274*^9}, {
   3.7716695970190773`*^9, 3.771669600389398*^9}, {3.771677568982067*^9, 
   3.7716775766050835`*^9}, {3.7716782969564185`*^9, 3.771678360053693*^9}, {
   3.7716784267759666`*^9, 3.7716784284344177`*^9}, {3.7716784911055613`*^9, 
   3.771678522673049*^9}, {3.7716785548654757`*^9, 3.771678589214897*^9}, {
   3.7716796500115128`*^9, 3.7716796836316442`*^9}, {3.771743068876005*^9, 
   3.7717430689298563`*^9}, {3.77174466019594*^9, 3.7717446622579923`*^9}, {
   3.771755638956787*^9, 3.7717556494710464`*^9}, {3.7717557338724613`*^9, 
   3.7717558208535852`*^9}, {3.7717564613961935`*^9, 3.771756483394667*^9}, {
   3.7717565588132677`*^9, 3.7717565847653637`*^9}, {3.771758180176942*^9, 
   3.7717581952406173`*^9}, {3.7719282620047493`*^9, 3.771928274281084*^9}, {
   3.773053676650999*^9, 3.773053690522129*^9}, 3.773063978148549*^9, {
   3.7731234898213634`*^9, 3.7731235282751245`*^9}, {3.775375371997332*^9, 
   3.7753753755161343`*^9}, {3.775381879597662*^9, 3.7753820307799625`*^9}, {
   3.7753822258368473`*^9, 3.775382269230371*^9}, {3.775382400406457*^9, 
   3.7753824182754817`*^9}, 3.775382551223713*^9, {3.77597032999426*^9, 
   3.775970330447278*^9}, {3.7759705888399467`*^9, 3.775970721027199*^9}, {
   3.7759710485869637`*^9, 3.7759710887198963`*^9}, {3.775971474224698*^9, 
   3.7759714748964148`*^9}, {3.775971532707755*^9, 3.7759715330955353`*^9}, {
   3.7759721163234186`*^9, 3.7759721173075643`*^9}, {3.7759738730554285`*^9, 
   3.7759740309008923`*^9}, {3.7759748008302064`*^9, 3.775974913086027*^9}, {
   3.7759750283600225`*^9, 3.775975032209963*^9}, {3.7759751833425517`*^9, 
   3.7759751865228715`*^9}, {3.7759754025482993`*^9, 3.77597544571861*^9}, {
   3.7759755157361407`*^9, 3.7759756273651576`*^9}, {3.7759757606940885`*^9, 
   3.775975784107974*^9}, {3.775976434150741*^9, 3.775976467643176*^9}, {
   3.7759765378057933`*^9, 3.775976600400424*^9}, {3.7759767817857*^9, 
   3.775976802977689*^9}, {3.77597691101481*^9, 3.7759769237682476`*^9}, {
   3.775977046928296*^9, 3.7759770513506327`*^9}, {3.775977139852575*^9, 
   3.7759772599952807`*^9}, {3.7759773025624247`*^9, 3.775977342687679*^9}, {
   3.775977809838889*^9, 3.775977812310458*^9}, {3.775978173456747*^9, 
   3.775978182960619*^9}, {3.7759783529285316`*^9, 3.7759783732318764`*^9}, {
   3.7759784908419094`*^9, 3.7759785383017845`*^9}, {3.7759787050729647`*^9, 
   3.7759787148939123`*^9}, {3.775978815087892*^9, 3.77597881521286*^9}, {
   3.775978887670947*^9, 3.7759789094696665`*^9}, {3.7759789669034915`*^9, 
   3.775978966965975*^9}, {3.77597905925445*^9, 3.77597905939504*^9}, {
   3.77597931651031*^9, 3.7759793438810096`*^9}, {3.775979393248663*^9, 
   3.775979396861303*^9}, {3.775979493900787*^9, 3.775979498870141*^9}, {
   3.7759795704519544`*^9, 3.7759795719515963`*^9}, {3.775980367498499*^9, 
   3.775980373688101*^9}, {3.7759804334722986`*^9, 3.7759804394118643`*^9}, {
   3.775980470034383*^9, 3.7759804759416084`*^9}, {3.7759805213187113`*^9, 
   3.7759805265232625`*^9}, {3.775980596710368*^9, 3.775980597866354*^9}, {
   3.775980685440336*^9, 3.775980701194945*^9}, {3.775980801032648*^9, 
   3.7759808040813193`*^9}, {3.775980906504019*^9, 3.775980943761853*^9}, {
   3.7759810222523394`*^9, 3.775981029988222*^9}, {3.775981071593402*^9, 
   3.775981137893276*^9}, {3.7759812064539804`*^9, 3.7759812173457317`*^9}, {
   3.775981267186038*^9, 3.7759812889275665`*^9}, {3.775981367822196*^9, 
   3.7759813933659244`*^9}, {3.7759814908037863`*^9, 3.775981512309603*^9}, {
   3.775982191035874*^9, 3.775982270888726*^9}, {3.775982659747901*^9, 
   3.775982715980893*^9}, {3.775983088714069*^9, 3.7759831014937725`*^9}, {
   3.775983479476821*^9, 3.775983494015912*^9}, {3.775984157083788*^9, 
   3.775984189105794*^9}, {3.775987638218315*^9, 3.775987669492136*^9}, {
   3.7759877882950287`*^9, 3.7759878103737164`*^9}, {3.7759879407630053`*^9, 
   3.77598794732751*^9}, {3.7759884426335487`*^9, 3.7759884433833733`*^9}, {
   3.7759903836128483`*^9, 3.7759903891335106`*^9}, {3.775990536786618*^9, 
   3.775990537630173*^9}, {3.775991052511698*^9, 3.77599109547548*^9}, {
   3.776056992233425*^9, 3.776057069303294*^9}, {3.776057153335003*^9, 
   3.7760571823878765`*^9}, {3.7760572182036057`*^9, 
   3.7760573256045346`*^9}, {3.77605742420984*^9, 3.7760574270080004`*^9}, {
   3.7760575890959277`*^9, 3.7760576223432865`*^9}, {3.776057657480855*^9, 
   3.776057745252927*^9}, {3.7760577990605288`*^9, 3.7760578380112743`*^9}, {
   3.7760604287191863`*^9, 3.77606046598678*^9}, {3.7760619884688883`*^9, 
   3.776062072334055*^9}, {3.7760627885494223`*^9, 3.7760627981098127`*^9}, {
   3.7760750179446545`*^9, 3.776075020666136*^9}, {3.7764888645709724`*^9, 
   3.7764889098753557`*^9}, {3.776489328125409*^9, 3.7764893391100535`*^9}, {
   3.77649131423363*^9, 3.7764913192681317`*^9}, {3.7764916880966997`*^9, 
   3.776491723375167*^9}, {3.7764926384497523`*^9, 3.7764927740143375`*^9}, {
   3.7764928183674555`*^9, 3.7764928867245255`*^9}, {3.7764945679353523`*^9, 
   3.7764946137514715`*^9}, {3.776495453736725*^9, 3.776495503977549*^9}, 
   3.7764955944029465`*^9, {3.776496911278183*^9, 3.7764969331721306`*^9}, 
   3.7764973570621305`*^9, {3.7764983447840176`*^9, 3.7764984575630236`*^9}, 
   3.7764985889090443`*^9, {3.776499585795329*^9, 3.776499585982813*^9}, {
   3.7764996323471537`*^9, 3.7764996341553574`*^9}, {3.7765011925631084`*^9, 
   3.776501230502634*^9}, 3.776501264702818*^9, {3.7765046444826655`*^9, 
   3.7765046472113724`*^9}, {3.776507174468521*^9, 3.7765072183103795`*^9}, 
   3.7765080755665674`*^9, {3.7782235757323546`*^9, 3.778223577241416*^9}, {
   3.7789220404263115`*^9, 3.7789220630006003`*^9}, 3.7789221044667997`*^9, {
   3.7789221359072857`*^9, 3.7789221586896644`*^9}, {3.7789237311543007`*^9, 
   3.7789237591190524`*^9}, {3.793018120756835*^9, 3.793018123576969*^9}, {
   3.7930181900905676`*^9, 3.7930181940923815`*^9}, 3.793035980039872*^9, {
   3.793106335043481*^9, 3.7931063531114197`*^9}, {3.7931164191303134`*^9, 
   3.7931164223439703`*^9}, {3.7967322254312787`*^9, 
   3.7967322355513597`*^9}, {3.850815071901292*^9, 3.850815145662879*^9}, {
   3.850815197881313*^9, 3.8508152428672905`*^9}, {3.8508157635682344`*^9, 
   3.850815764572797*^9}, 3.8508158040356255`*^9, {3.8508159263986874`*^9, 
   3.850815999633526*^9}, {3.8508163057829022`*^9, 3.850816437935964*^9}, {
   3.8508165313410544`*^9, 3.8508165578528976`*^9}, {3.8508172704911513`*^9, 
   3.8508173648959455`*^9}, {3.8508174125181413`*^9, 3.850817448754005*^9}, {
   3.850817524639171*^9, 3.850817542477711*^9}, {3.8508178137828074`*^9, 
   3.850817909907736*^9}, {3.850817951898738*^9, 3.850817977069121*^9}, {
   3.850818028669967*^9, 3.850818051351202*^9}, {3.8508181159191933`*^9, 
   3.8508182065049405`*^9}, {3.8508182806895823`*^9, 3.850818289336316*^9}, {
   3.8508183258070726`*^9, 3.8508183278359127`*^9}, {3.8508183612051325`*^9, 
   3.850818518286129*^9}, 3.8508187239545207`*^9, {3.8508191343984995`*^9, 
   3.8508191719869356`*^9}, {3.850819203089984*^9, 3.8508192378455715`*^9}, {
   3.850819374412201*^9, 3.8508194645888433`*^9}, {3.8508195601210756`*^9, 
   3.8508195638604155`*^9}, {3.850819624672181*^9, 3.8508196262779903`*^9}, {
   3.850820859240729*^9, 3.8508208774604807`*^9}, {3.8508209194455457`*^9, 
   3.8508209194960556`*^9}, {3.8508209926938763`*^9, 
   3.8508210759473886`*^9}, {3.8508212992217264`*^9, 3.850821351212199*^9}, {
   3.8508213849875965`*^9, 3.850821385270567*^9}, {3.8508214317950125`*^9, 
   3.850821431826255*^9}, {3.850821766102844*^9, 3.850821766322113*^9}, {
   3.850821869018364*^9, 3.8508218695507617`*^9}, {3.851066448608245*^9, 
   3.851066571604802*^9}, {3.8510677122401686`*^9, 3.8510677202160645`*^9}, {
   3.8510677602121325`*^9, 3.8510677603168793`*^9}, {3.851068299298009*^9, 
   3.8510683006971684`*^9}, {3.851068361487043*^9, 3.8510683615503273`*^9}, {
   3.8510684160078335`*^9, 3.8510684183915997`*^9}, {3.851244497790783*^9, 
   3.851244498786951*^9}, {3.851244626091014*^9, 3.851244714202984*^9}, {
   3.851245150163892*^9, 3.8512451920731745`*^9}, {3.8512452716592216`*^9, 
   3.851245310134405*^9}, {3.851245398444007*^9, 3.8512454339756737`*^9}, {
   3.8512454742038546`*^9, 3.851245487566362*^9}, {3.851245575998826*^9, 
   3.851245587367607*^9}, {3.851245638407413*^9, 3.8512456473975353`*^9}, {
   3.8512457116661315`*^9, 3.8512457514701896`*^9}, {3.8512458350424633`*^9, 
   3.8512458355652323`*^9}, {3.8512460437177954`*^9, 
   3.8512460526177845`*^9}, {3.851246833264872*^9, 3.851246839328143*^9}, 
   3.8515073074169846`*^9, {3.8515843192092533`*^9, 3.8515844129961185`*^9}, {
   3.851585337198927*^9, 3.851585360372138*^9}, {3.851585431525842*^9, 
   3.8515854316039305`*^9}, {3.8515854820832176`*^9, 
   3.8515855703664465`*^9}, {3.8515930943493557`*^9, 3.851593116326378*^9}, {
   3.8515989505738935`*^9, 3.8515990154321346`*^9}, {3.8515995803717666`*^9, 
   3.8515996267197533`*^9}, {3.8515996713801394`*^9, 
   3.8515996800113115`*^9}, {3.8515997363257847`*^9, 3.85159999931383*^9}, {
   3.851600033455225*^9, 3.851600134416837*^9}, {3.8516010606418095`*^9, 
   3.8516010688388968`*^9}, 3.8516011500463095`*^9, 3.851601215675002*^9, 
   3.851601279457867*^9, {3.8516013097126813`*^9, 3.851601317392064*^9}, {
   3.8516013588555727`*^9, 3.8516013713631744`*^9}, {3.8516014666488047`*^9, 
   3.851601478681609*^9}, {3.8516025452004075`*^9, 3.851602548415313*^9}, {
   3.851602820176403*^9, 3.8516028465755615`*^9}, {3.8516033373950195`*^9, 
   3.8516034345210996`*^9}, {3.851621545072527*^9, 3.851621548374962*^9}, {
   3.8516779381472816`*^9, 3.8516779864021745`*^9}, {3.8516780826477985`*^9, 
   3.851678083654154*^9}, {3.8516781334958196`*^9, 3.851678146322188*^9}, {
   3.851678232375604*^9, 3.851678237254529*^9}, 3.8516782689105024`*^9, {
   3.851678465799469*^9, 3.851678503397095*^9}, {3.8516785920857687`*^9, 
   3.8516785930712414`*^9}, {3.8516786286088343`*^9, 
   3.8516786354899387`*^9}, {3.8516786883465385`*^9, 3.85167869810627*^9}, {
   3.851678748116455*^9, 3.8516787543592625`*^9}, {3.851678811164028*^9, 
   3.8516788220481887`*^9}, {3.8517717832289643`*^9, 3.851771813727523*^9}, {
   3.8520192743399525`*^9, 3.852019379160453*^9}, {3.8520194170292535`*^9, 
   3.8520194213815265`*^9}, {3.852019457415291*^9, 3.8520194574756126`*^9}, {
   3.852019504114106*^9, 3.8520195463216925`*^9}, {3.852370973631966*^9, 
   3.8523710001138687`*^9}, 3.8523726445015216`*^9, {3.8523727353964796`*^9, 
   3.8523727484400077`*^9}, {3.852372791898356*^9, 3.8523728532164497`*^9}, {
   3.8523728971737595`*^9, 3.852372899772915*^9}, {3.8523729319196367`*^9, 
   3.8523729414218884`*^9}, {3.8523729718712206`*^9, 
   3.8523730143618307`*^9}, {3.8526358241261435`*^9, 
   3.8526358330001802`*^9}, {3.8526395447297506`*^9, 3.852639548220919*^9}, {
   3.8630862493517284`*^9, 3.8630862719769983`*^9}, {3.8630881882553988`*^9, 
   3.863088208072644*^9}, {3.8630894702658124`*^9, 3.8630894722184815`*^9}, {
   3.86351768537838*^9, 3.863517735920988*^9}, 3.894355433126083*^9, {
   3.89435619291395*^9, 3.894356213612858*^9}, {3.89435624432856*^9, 
   3.894356294931017*^9}, {3.8943563432035513`*^9, 3.894356354866317*^9}, {
   3.89435640842599*^9, 3.8943564154093237`*^9}, {3.894356453901175*^9, 
   3.8943564585416317`*^9}, {3.894356492234269*^9, 3.894356505102729*^9}, {
   3.894356575445203*^9, 3.894356599431712*^9}, {3.894356718083803*^9, 
   3.894356725280818*^9}, {3.894356793769631*^9, 3.894356815522719*^9}, {
   3.894356902844515*^9, 3.894356938880728*^9}, {3.894356986675679*^9, 
   3.894356994042242*^9}, {3.894358383139464*^9, 3.894358386837929*^9}, {
   3.894360858693782*^9, 3.89436086237257*^9}, {3.894428874233198*^9, 
   3.8944288757796087`*^9}, 3.894429267987933*^9, 3.894598675247448*^9, {
   3.8949628393715878`*^9, 3.8949628985267677`*^9}, {3.8949631164846992`*^9, 
   3.894963116853416*^9}, {3.894963405460121*^9, 3.894963407901166*^9}, {
   3.8949637647530193`*^9, 3.8949637891672297`*^9}, {3.8949638302535458`*^9, 
   3.894963843007197*^9}, 3.8949640691256*^9, {3.89496450365071*^9, 
   3.894964513788651*^9}, {3.894964861542099*^9, 3.894964861691476*^9}, {
   3.8949651462950363`*^9, 3.894965156337188*^9}, 3.894965201134613*^9, {
   3.894965437876664*^9, 3.8949654509984922`*^9}, {3.8949658758313932`*^9, 
   3.8949658783391933`*^9}, {3.894965908476426*^9, 3.894965959668703*^9}, 
   3.89496622668543*^9, {3.894966504565908*^9, 3.8949665050682087`*^9}, {
   3.89496690009731*^9, 3.894966902087474*^9}, 3.894966963649662*^9, 
   3.894967089325943*^9, {3.8967586153018847`*^9, 3.896758618793507*^9}, {
   3.8985229570221663`*^9, 3.89852295756607*^9}, {3.898523009221813*^9, 
   3.898523031804574*^9}, {3.8985868831652193`*^9, 3.898586912982183*^9}, {
   3.898586980307013*^9, 3.898586981896694*^9}, {3.898588083010705*^9, 
   3.898588138147753*^9}, {3.8985882509066477`*^9, 3.898588257861258*^9}, {
   3.898588386465019*^9, 3.8985883874519997`*^9}, 3.898588872783299*^9, {
   3.8986827652733583`*^9, 3.8986827782734623`*^9}, {3.898683960479742*^9, 
   3.898683986130227*^9}, {3.898684016247035*^9, 3.8986840262438383`*^9}, {
   3.898684430172763*^9, 3.898684432084651*^9}, 3.898743696792676*^9, {
   3.899303067800688*^9, 3.89930309155694*^9}, {3.899352061472444*^9, 
   3.899352065052074*^9}, {3.899356170106751*^9, 3.899356178568878*^9}, 
   3.8993569505762873`*^9, 3.8993570244247417`*^9, 3.899357063106043*^9, {
   3.899373003061851*^9, 3.899373026396669*^9}, 3.8997827844361267`*^9, {
   3.899960365906108*^9, 3.899960369470643*^9}, {3.899962621559903*^9, 
   3.89996262176197*^9}, {3.8999626683090353`*^9, 3.899962686187715*^9}, 
   3.8999627425339108`*^9, 3.89996277529149*^9, {3.899962807852868*^9, 
   3.8999629038119297`*^9}, {3.8999629978385363`*^9, 3.899963015598456*^9}, {
   3.899963604945134*^9, 3.899963651581974*^9}, {3.899963684059066*^9, 
   3.899963686279986*^9}, {3.899963723129971*^9, 3.899963769800002*^9}, {
   3.8999639660207567`*^9, 3.89996400059144*^9}, {3.899973724022591*^9, 
   3.8999737654518347`*^9}, {3.899974797126192*^9, 3.8999747979234343`*^9}, {
   3.899974869890026*^9, 3.899974956335977*^9}, {3.899975006579522*^9, 
   3.8999751132076178`*^9}, {3.899975345275909*^9, 3.899975393513893*^9}, {
   3.89997548073106*^9, 3.8999755780410643`*^9}, {3.899975649987844*^9, 
   3.899975651374611*^9}, {3.8999763250871687`*^9, 3.8999763274121532`*^9}, {
   3.8999763843652277`*^9, 3.899976500145768*^9}, {3.899976539598111*^9, 
   3.899976574297187*^9}, {3.899976615650041*^9, 3.899976623469557*^9}, {
   3.8999767156333437`*^9, 3.899976743837624*^9}, 3.899976796201906*^9, 
   3.899976829566496*^9, 3.899976862164646*^9, {3.899976893541089*^9, 
   3.899976914672516*^9}, {3.899977013048127*^9, 3.899977017521236*^9}, {
   3.899977057436561*^9, 3.89997712363671*^9}, {3.8999771593323507`*^9, 
   3.899977162907105*^9}, {3.899977216942017*^9, 3.8999772686521587`*^9}, {
   3.899977486820218*^9, 3.899977511157488*^9}, {3.899977561789509*^9, 
   3.899977569406034*^9}, {3.899977702475119*^9, 3.8999777186701813`*^9}, {
   3.8999787511992064`*^9, 3.899978772512678*^9}, {3.900037497713372*^9, 
   3.90003753897268*^9}, {3.900037599397575*^9, 3.9000376304605618`*^9}, {
   3.900037660944107*^9, 3.900037665982645*^9}, 3.900037700905188*^9, {
   3.900037755099834*^9, 3.900037766479187*^9}, {3.900037821405175*^9, 
   3.9000378555444403`*^9}, {3.900042640776866*^9, 3.900042663205771*^9}, 
   3.900042702296258*^9, {3.900042756110458*^9, 3.900042798203248*^9}, 
   3.900042895306079*^9, 3.900042979375983*^9, {3.900043295927347*^9, 
   3.9000433236368723`*^9}, {3.900043358314171*^9, 3.900043372037479*^9}, {
   3.900043494141584*^9, 3.9000435310112267`*^9}, {3.9000435831595907`*^9, 
   3.90004358874264*^9}, {3.900043625221874*^9, 3.9000436269378967`*^9}, {
   3.900043730930073*^9, 3.9000437314174833`*^9}, {3.9000444962936983`*^9, 
   3.90004449832516*^9}, {3.90004467048943*^9, 3.9000447058915157`*^9}, {
   3.90004474428573*^9, 3.9000447739367647`*^9}, {3.90004555525051*^9, 
   3.900045568025834*^9}, {3.9000457592042723`*^9, 3.900045760665436*^9}, 
   3.900047575521502*^9, {3.9000491163631*^9, 3.9000491234323874`*^9}, {
   3.900049171705428*^9, 3.900049180974633*^9}, {3.900049483456459*^9, 
   3.900049491299494*^9}, {3.900049527264529*^9, 3.900049552565206*^9}, {
   3.9000496141374493`*^9, 3.900049628684332*^9}, {3.900051752883707*^9, 
   3.9000517578402967`*^9}, {3.900051790540165*^9, 3.9000518050721283`*^9}, {
   3.9000571231457148`*^9, 3.900057133725564*^9}, {3.9000645440692863`*^9, 
   3.9000645612536573`*^9}, {3.900064686294559*^9, 3.900064700188469*^9}, 
   3.900064841034123*^9, {3.900064929648896*^9, 3.900064931592473*^9}, {
   3.900064969260388*^9, 3.900064972983345*^9}, {3.900065011910409*^9, 
   3.9000650295429487`*^9}, 3.900065123189918*^9, {3.9000651651233473`*^9, 
   3.900065171896928*^9}, {3.9000652864859953`*^9, 3.9000652893585978`*^9}, {
   3.900065485254778*^9, 3.900065551525502*^9}, {3.900065617470961*^9, 
   3.900065628134952*^9}, {3.900065663948167*^9, 3.900065687049327*^9}, {
   3.900065794888681*^9, 3.900065794998294*^9}, {3.900130518397912*^9, 
   3.9001305218046923`*^9}, {3.900130561403818*^9, 3.9001305643466578`*^9}, {
   3.9001309835090637`*^9, 3.9001309971641283`*^9}, {3.9001310356597347`*^9, 
   3.900131075960161*^9}, 3.900131121802352*^9, {3.900131207587802*^9, 
   3.900131298269874*^9}, {3.900131779196395*^9, 3.9001318538309803`*^9}, 
   3.900131910606408*^9, {3.900133793091607*^9, 3.9001337950406322`*^9}, {
   3.900133891360774*^9, 3.90013389314774*^9}, {3.900133963073927*^9, 
   3.9001339969759483`*^9}, {3.900136754876088*^9, 3.900136785801036*^9}, {
   3.900136831363851*^9, 3.900136839707196*^9}, 3.900136991130328*^9, {
   3.900137120265018*^9, 3.900137122432065*^9}, {3.900137162699699*^9, 
   3.900137260109084*^9}, {3.900137302676311*^9, 3.9001373277116823`*^9}, {
   3.900138211705031*^9, 3.900138213579795*^9}, {3.900138254881619*^9, 
   3.9001382745812674`*^9}, {3.900138333010788*^9, 3.90013833613581*^9}, {
   3.9001383756053123`*^9, 3.900138393816921*^9}, {3.9001384461902933`*^9, 
   3.900138449078137*^9}, {3.900138521671077*^9, 3.900138531205223*^9}, {
   3.900142120079451*^9, 3.900142125991477*^9}, {3.900142184974125*^9, 
   3.90014219168034*^9}, {3.900142286316362*^9, 3.900142301577483*^9}, {
   3.900142379536171*^9, 3.900142386697192*^9}, {3.900142555203866*^9, 
   3.9001425566318007`*^9}, {3.900142598829537*^9, 3.900142599131607*^9}, {
   3.900143446187026*^9, 3.900143472966752*^9}, {3.900143546535573*^9, 
   3.900143549637898*^9}, 3.9001448131257668`*^9, {3.900147017182789*^9, 
   3.900147022808426*^9}, {3.900147655660061*^9, 3.900147658367136*^9}, 
   3.9001516438525133`*^9, {3.900164492888454*^9, 3.9001644931382113`*^9}, {
   3.900242980151059*^9, 3.9002429916048098`*^9}, 3.9002439317594547`*^9, 
   3.900401859688898*^9, {3.9004731898596277`*^9, 3.900473189890955*^9}, 
   3.900474269652259*^9, {3.900474813737794*^9, 3.900474816320367*^9}, {
   3.900475749233333*^9, 3.9004757510078287`*^9}, 3.900475783702032*^9, 
   3.900475841293212*^9, {3.900476005661809*^9, 3.900476008976737*^9}, {
   3.90047607777339*^9, 3.90047610421059*^9}, {3.9004762216982517`*^9, 
   3.900476236368877*^9}, {3.900476320675267*^9, 3.900476325732636*^9}, {
   3.900476588784958*^9, 3.900476593864959*^9}, {3.900480575256442*^9, 
   3.900480577276597*^9}, 3.900592717902204*^9, {3.900601846801182*^9, 
   3.900601849848979*^9}, {3.9006019814655647`*^9, 3.90060198553913*^9}, {
   3.900641374967004*^9, 3.900641383582468*^9}, {3.9006616298878403`*^9, 
   3.900661660520175*^9}, {3.900661782263537*^9, 3.900661783441543*^9}, {
   3.900661829528598*^9, 3.9006619123654203`*^9}, 3.900662042545307*^9, {
   3.9006621644590178`*^9, 3.900662180142685*^9}, 3.9007345517941723`*^9, {
   3.900750928221032*^9, 3.9007510156636744`*^9}, {3.9007523532396584`*^9, 
   3.900752407529215*^9}, {3.900752644220317*^9, 3.90075264726122*^9}, {
   3.9007553808942337`*^9, 3.9007553864684677`*^9}, {3.900776008345902*^9, 
   3.900776013287644*^9}, 3.900776201018923*^9, 3.901178502478489*^9, {
   3.901178538920045*^9, 3.901178547596128*^9}, {3.901178645711266*^9, 
   3.901178696849584*^9}, {3.9011787300320587`*^9, 3.901178734836515*^9}, {
   3.901179372003331*^9, 3.901179407359744*^9}, {3.9011798933441973`*^9, 
   3.901179935122312*^9}, {3.901180028186841*^9, 3.901180054769009*^9}, {
   3.9011802745648737`*^9, 3.901180275894939*^9}, {3.901185223844481*^9, 
   3.901185223968746*^9}, {3.901185330932022*^9, 3.901185337346661*^9}, {
   3.901185929552156*^9, 3.901185939719792*^9}, 3.9011979281443157`*^9, {
   3.901197960273704*^9, 3.9011979741010857`*^9}, {3.901200304826161*^9, 
   3.901200310275889*^9}, {3.901201400034584*^9, 3.901201410320999*^9}, {
   3.9012074116500397`*^9, 3.90120741753441*^9}, {3.9012078520102262`*^9, 
   3.901207853269916*^9}, 3.901210698735909*^9, {3.90121073356256*^9, 
   3.901210744865211*^9}, {3.901251320777245*^9, 3.901251321145013*^9}, {
   3.901252748057042*^9, 3.901252754696863*^9}, {3.901252941623168*^9, 
   3.901252964817429*^9}, 3.901253015880423*^9, {3.903069549950625*^9, 
   3.903069619328555*^9}, {3.903069654142303*^9, 3.9030697041970587`*^9}},
 CellLabel->"In[54]:=",ExpressionUUID->"0d33c2cf-e40d-40a6-b15a-5d60da41384a"]
}, Closed]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{
   RowBox[{
    RowBox[{"pointsInitToParms", "[", "pointsInit_", "]"}], " ", "-", " ", 
    RowBox[{
    "takes", " ", "pointsInit", " ", "the", " ", "input", " ", "used", " ", 
     "in", " ", "solving", " ", "the", " ", "baseline", " ", "model"}]}], ",",
    " ", "SolveModel", ",", " ", 
   RowBox[{
   "and", " ", "returns", " ", "only", " ", "the", " ", "fixed", " ", 
    "parameters", " ", "used", " ", "in", " ", "startPoints"}]}], 
  "*)"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.},
 CellChangeTimes->{{3.796900153528643*^9, 3.7969002254220943`*^9}},
 CellLabel->"In[55]:=",ExpressionUUID->"893438a8-9aec-4dd9-9970-69e9a87b4b6e"],

Cell[BoxData[
 RowBox[{
  RowBox[{
   RowBox[{"pointsInitToParms", "[", "pointsInit_", "]"}], ":=", 
   RowBox[{"Join", "[", 
    RowBox[{
     RowBox[{"pointsInit", "[", 
      RowBox[{"[", 
       RowBox[{"3", ";;", "13"}], "]"}], "]"}], ",", 
     RowBox[{"{", 
      RowBox[{"pointsInit", "[", 
       RowBox[{"[", "17", "]"}], "]"}], "}"}]}], "]"}]}], ";"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.},
 CellChangeTimes->{
  3.7950061085228014`*^9, {3.795010040209591*^9, 3.7950100436940174`*^9}, {
   3.79689979096169*^9, 3.796899796839001*^9}, {3.796899995306369*^9, 
   3.796899997720352*^9}, {3.7969001514093323`*^9, 3.796900152567218*^9}, {
   3.7969001957358174`*^9, 3.796900208589552*^9}, 3.900127864710909*^9},
 CellLabel->"In[56]:=",ExpressionUUID->"5653b452-5861-4ca2-8fa8-a5a4e15bd213"]
}, Closed]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{
   RowBox[{"startPoints", "[", 
    RowBox[{"parms_", ",", "ansBaseline_", ",", "tindex_"}], "]"}], " ", "-", 
   " ", 
   RowBox[{
   "takes", " ", "parameters", " ", "and", " ", "solution", " ", "and", " ", 
    "returns", " ", "the", " ", "start", " ", "points", " ", "at", " ", 
    "time", " ", "tindex"}]}], "*)"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.},
 CellChangeTimes->{{3.7950060890218124`*^9, 3.7950061085228014`*^9}, 
   3.90013376807654*^9},
 CellLabel->"In[57]:=",ExpressionUUID->"9ea4e1ba-0732-4533-a925-e31e16f5b11f"],

Cell[BoxData[
 RowBox[{
  RowBox[{
   RowBox[{"startPoints", "[", 
    RowBox[{"parms_", ",", "ansBaseline_", ",", "tindex_"}], "]"}], ":=", 
   RowBox[{"Module", "[", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"nInitxtemp", ",", "kInitxtemp", ",", "\[Beta]xtemp", ",", 
       RowBox[{"parmstemp", "=", "parms"}], ",", "atemp", ",", "Deetemp", ",",
        "pietemp"}], "}"}], ",", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"nInitxtemp", "=", 
       RowBox[{"ansBaseline", "[", 
        RowBox[{"[", 
         RowBox[{"2", ",", 
          RowBox[{"tindex", "+", "1"}], ",", "1", ",", "All", ",", "2"}], 
         "]"}], "]"}]}], ";", "\[IndentingNewLine]", 
      RowBox[{"kInitxtemp", "=", 
       RowBox[{"ansBaseline", "[", 
        RowBox[{"[", 
         RowBox[{"2", ",", 
          RowBox[{"tindex", "+", "1"}], ",", "2", ",", "All", ",", "2"}], 
         "]"}], "]"}]}], ";", "\[IndentingNewLine]", 
      RowBox[{"\[Beta]xtemp", "=", 
       RowBox[{"ansBaseline", "[", 
        RowBox[{"[", 
         RowBox[{"2", ",", 
          RowBox[{"tindex", "+", "1"}], ",", "3", ",", "All", ",", "2"}], 
         "]"}], "]"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"atemp", "=", 
       RowBox[{
        RowBox[{"parms", "[", 
         RowBox[{"[", 
          RowBox[{"2", ",", "2"}], "]"}], "]"}], "[", 
        RowBox[{"[", 
         RowBox[{
          RowBox[{"tindex", "+", "1"}], ";;", 
          RowBox[{"-", "1"}]}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", 
      RowBox[{"Deetemp", "=", 
       RowBox[{
        RowBox[{"parms", "[", 
         RowBox[{"[", 
          RowBox[{"4", ",", "2"}], "]"}], "]"}], "[", 
        RowBox[{"[", 
         RowBox[{
          RowBox[{"tindex", "+", "1"}], ";;", 
          RowBox[{"-", "1"}]}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", 
      RowBox[{"pietemp", "=", 
       RowBox[{
        RowBox[{"parms", "[", 
         RowBox[{"[", 
          RowBox[{"8", ",", "2"}], "]"}], "]"}], "[", 
        RowBox[{"[", 
         RowBox[{
          RowBox[{"tindex", "+", "1"}], ";;", 
          RowBox[{"-", "1"}]}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"parmstemp", "[", 
        RowBox[{"[", 
         RowBox[{"2", ",", "2"}], "]"}], "]"}], "=", "atemp"}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"parmstemp", "[", 
        RowBox[{"[", 
         RowBox[{"4", ",", "2"}], "]"}], "]"}], "=", "Deetemp"}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"parmstemp", "[", 
        RowBox[{"[", 
         RowBox[{"8", ",", "2"}], "]"}], "]"}], "=", "pietemp"}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"Join", "[", 
       RowBox[{
        RowBox[{"{", 
         RowBox[{
          RowBox[{"nInitx", "->", "nInitxtemp"}], ",", 
          RowBox[{"kInitx", "->", "kInitxtemp"}], ",", 
          RowBox[{"\[Beta]x", "->", "\[Beta]xtemp"}]}], "}"}], ",", 
        "parmstemp"}], "]"}]}]}], "]"}]}], "\n"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.},
 CellChangeTimes->{{3.900132890033452*^9, 3.900133089091485*^9}, {
   3.9001331297127867`*^9, 3.9001331532049913`*^9}, {3.900133200929818*^9, 
   3.900133309471334*^9}, 3.900133768076668*^9, {3.900133819818013*^9, 
   3.900133819934807*^9}},
 CellLabel->"In[58]:=",ExpressionUUID->"0313b796-1788-4d29-aa53-77b7c9ab3f56"]
}, Closed]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{
   RowBox[{
    RowBox[{"Mutatec0", "[", 
     RowBox[{
     "initVector_", ",", "beta_", ",", "fromBetaType_", ",", "toBetaType_", 
      ",", "proportionN_"}], "]"}], " ", "-", " ", 
    RowBox[{"Suppose", " ", "that", " ", "a", " ", "fraction", " ", 
     RowBox[{"(", "proportionN", ")"}], " ", "of", " ", "the", " ", "dynasty",
      " ", "with", " ", "beta", " ", "fromBetaType"}]}], ",", " ", 
   RowBox[{
   "mutates", " ", "to", " ", "a", " ", "dynasty", " ", "with", " ", "beta", 
    " ", 
    RowBox[{"toBetaType", ".", " ", "Generate"}], " ", "a", " ", "c0", " ", 
    "guess", " ", "for", " ", "this", " ", "mutation", " ", "from", " ", "a", 
    " ", "c0"}]}], " ", "*)"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10006.},
 CellChangeTimes->{{3.903069739333688*^9, 3.9030697399401903`*^9}, {
  3.903072139499467*^9, 3.9030721396522903`*^9}},
 CellLabel->"In[71]:=",ExpressionUUID->"de67cd4f-4898-4682-9364-758f4e937115"],

Cell[BoxData[
 RowBox[{
  RowBox[{
   RowBox[{"Mutatec0", "[", 
    RowBox[{
    "initVector_", ",", "beta_", ",", "fromBetaType_", ",", "toBetaType_", 
     ",", "proportionN_"}], "]"}], ":=", "\[IndentingNewLine]", 
   RowBox[{"Module", "[", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{
       RowBox[{"c0", "=", "initVector"}], ",", 
       RowBox[{"b", "=", "beta"}], ",", 
       RowBox[{"fromBType", "=", "fromBetaType"}], ",", 
       RowBox[{"toType", "=", "toBetaType"}], ",", 
       RowBox[{"propN", "=", "proportionN"}], ",", "c0prime", ",", "posOld", 
       ",", "posNew", ",", "posInsert"}], "}"}], ",", "\[IndentingNewLine]", 
     "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"posOld", "=", 
       RowBox[{
        RowBox[{"Position", "[", 
         RowBox[{"b", ",", "fromBetaType"}], "]"}], "[", 
        RowBox[{"[", 
         RowBox[{"1", ",", "1"}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", 
      RowBox[{"posNew", "=", 
       RowBox[{
        RowBox[{"Position", "[", 
         RowBox[{"b", ",", "toBetaType"}], "]"}], "[", 
        RowBox[{"[", 
         RowBox[{"1", ",", "1"}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", 
      RowBox[{"posInsert", "=", 
       RowBox[{"posNew", "+", "1"}]}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"c0prime", "=", "c0"}], ";", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"c0prime", "[", 
        RowBox[{"[", "posOld", "]"}], "]"}], "=", 
       RowBox[{
        RowBox[{"c0", "[", 
         RowBox[{"[", "posOld", "]"}], "]"}], "*", 
        RowBox[{"(", 
         RowBox[{"1", "-", "propN"}], ")"}]}]}], ";", "\[IndentingNewLine]", 
      RowBox[{"c0prime", "=", 
       RowBox[{"Insert", "[", 
        RowBox[{"c0prime", ",", 
         RowBox[{
          RowBox[{"c0", "[", 
           RowBox[{"[", "posOld", "]"}], "]"}], "*", "propN"}], ",", 
         "posInsert"}], "]"}]}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"Return", "[", "c0prime", "]"}], ";"}]}], "\[IndentingNewLine]",
     "\[IndentingNewLine]", "\[IndentingNewLine]", "]"}]}], ";"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10006.},
 CellLabel->"In[59]:=",ExpressionUUID->"6609e521-4ae3-4e2b-a36c-3044827a29b8"]
}, Closed]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{
   RowBox[{
    RowBox[{
     RowBox[{"Mutate", "[", 
      RowBox[{
      "initVector_", ",", "fromBetaType_", ",", "toBetaType_", ",", 
       "proportionN_", ",", "proportionK_"}], "]"}], " ", "--"}], " ", 
    "Suppose", " ", "that", " ", "a", " ", "fraction", " ", 
    RowBox[{"(", "proportionN", ")"}], " ", "of", " ", "the", " ", "dynasty", 
    " ", "with", " ", "beta", " ", "fromBetaType"}], ",", " ", 
   RowBox[{
   "mutates", " ", "to", " ", "a", " ", "dynasty", " ", "with", " ", "beta", 
    " ", 
    RowBox[{"toBetaType", ".", " ", "Suppose"}], " ", "also", " ", "they", 
    " ", "take", " ", "a", " ", "fraction", " ", "of", " ", "capital", " ", 
    "proportionK", " ", "with", " ", "themselves"}]}], "*)"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10005.},
 CellChangeTimes->{{3.903069752928936*^9, 3.903069754859524*^9}},
 CellLabel->"In[60]:=",ExpressionUUID->"0ac80e0c-85fc-46c5-b89b-8a7c4caf2cbb"],

Cell[BoxData[
 RowBox[{
  RowBox[{
   RowBox[{"Mutate", "[", 
    RowBox[{
    "initVector_", ",", "fromBetaType_", ",", "toBetaType_", ",", 
     "proportionN_", ",", "proportionK_"}], "]"}], ":=", 
   "\[IndentingNewLine]", 
   RowBox[{"Module", "[", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{
       RowBox[{"initAll", "=", "initVector"}], ",", 
       RowBox[{"fromBType", "=", "fromBetaType"}], ",", 
       RowBox[{"toType", "=", "toBetaType"}], ",", 
       RowBox[{"propN", "=", "proportionN"}], ",", 
       RowBox[{"propK", "=", "proportionK"}], ",", "b", ",", "n", ",", "k", 
       ",", " ", "bprime", ",", "nprime", ",", "kprime", ",", "posOld", ",", 
       "posNew", ",", "posInsert"}], "}"}], ",", "\[IndentingNewLine]", 
     "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"n", "=", 
       RowBox[{"initAll", "[", 
        RowBox[{"[", 
         RowBox[{"1", ",", "2"}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", 
      RowBox[{"k", "=", 
       RowBox[{"initAll", "[", 
        RowBox[{"[", 
         RowBox[{"2", ",", "2"}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", 
      RowBox[{"b", "=", 
       RowBox[{"initAll", "[", 
        RowBox[{"[", 
         RowBox[{"3", ",", "2"}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"posOld", "=", 
       RowBox[{
        RowBox[{"Position", "[", 
         RowBox[{"b", ",", "fromBetaType"}], "]"}], "[", 
        RowBox[{"[", 
         RowBox[{"1", ",", "1"}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", 
      RowBox[{"posNew", "=", 
       RowBox[{
        RowBox[{"Position", "[", 
         RowBox[{"b", ",", "toBetaType"}], "]"}], "[", 
        RowBox[{"[", 
         RowBox[{"1", ",", "1"}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", 
      RowBox[{"posInsert", "=", 
       RowBox[{"posNew", "+", "1"}]}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"bprime", "=", 
       RowBox[{"Insert", "[", 
        RowBox[{"b", ",", "toBetaType", ",", "posInsert"}], "]"}]}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{"kprime", "=", "k"}], ";", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"kprime", "[", 
        RowBox[{"[", "posOld", "]"}], "]"}], "=", 
       RowBox[{
        RowBox[{"k", "[", 
         RowBox[{"[", "posOld", "]"}], "]"}], "*", 
        RowBox[{"(", 
         RowBox[{"1", "-", "propK"}], ")"}]}]}], ";", "\[IndentingNewLine]", 
      RowBox[{"kprime", "=", 
       RowBox[{"Insert", "[", 
        RowBox[{"kprime", ",", 
         RowBox[{
          RowBox[{"k", "[", 
           RowBox[{"[", "posOld", "]"}], "]"}], "*", "propK"}], ",", 
         "posInsert"}], "]"}]}], ";", "\[IndentingNewLine]", 
      RowBox[{"nprime", "=", "n"}], ";", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"nprime", "[", 
        RowBox[{"[", "posOld", "]"}], "]"}], "=", 
       RowBox[{
        RowBox[{"n", "[", 
         RowBox[{"[", "posOld", "]"}], "]"}], "*", 
        RowBox[{"(", 
         RowBox[{"1", "-", "propN"}], ")"}]}]}], ";", "\[IndentingNewLine]", 
      RowBox[{"nprime", "=", 
       RowBox[{"Insert", "[", 
        RowBox[{"nprime", ",", 
         RowBox[{
          RowBox[{"n", "[", 
           RowBox[{"[", "posOld", "]"}], "]"}], "*", "propN"}], ",", 
         "posInsert"}], "]"}]}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"initAll", "[", 
        RowBox[{"[", 
         RowBox[{"1", ",", "2"}], "]"}], "]"}], "=", "nprime"}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"initAll", "[", 
        RowBox[{"[", 
         RowBox[{"2", ",", "2"}], "]"}], "]"}], "=", "kprime"}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"initAll", "[", 
        RowBox[{"[", 
         RowBox[{"3", ",", "2"}], "]"}], "]"}], "=", "bprime"}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{"Return", "[", "initAll", "]"}], ";"}]}], "\[IndentingNewLine]",
     "\[IndentingNewLine]", "\[IndentingNewLine]", "]"}]}], ";"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10005.},
 CellLabel->"In[61]:=",ExpressionUUID->"25f0e9fd-2df7-45cb-8d0c-17335c26b7ed"],

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{"Mutate", "[", 
   RowBox[{
   "initVector_", ",", "fromBetaType_", ",", "toBetaType_", ",", 
    "proportionN_", ",", "proportionK_"}], "]"}], "*)"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10005.},
 CellLabel->"In[62]:=",ExpressionUUID->"a161a501-b618-42fc-b252-b0b5d3d66dbb"]
}, Closed]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{
   RowBox[{"score", "[", 
    RowBox[{"c0sh_", ",", "points_"}], "]"}], " ", "-", " ", 
   RowBox[{
   "a", " ", "score", " ", "determining", " ", "how", " ", "close", " ", 
    "the", " ", "initial", " ", "guess", " ", "of", " ", "consumption", " ", 
    "distributions", " ", "is", " ", "to", " ", "the", " ", "correct", " ", 
    "score", " ", "of", " ", "zero"}]}], "*)"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.},
 CellChangeTimes->{{3.7950038196397038`*^9, 3.795003823722966*^9}, 
   3.79949307454843*^9, 3.900641156147545*^9, {3.903069769614944*^9, 
   3.903069792963358*^9}},
 CellLabel->"In[63]:=",ExpressionUUID->"d3d167fe-d724-4c05-acb0-27e21ebedae6"],

Cell[BoxData[
 RowBox[{
  RowBox[{
   RowBox[{"score", "[", 
    RowBox[{"c0sh_", ",", "points_"}], "]"}], ":=", 
   RowBox[{"Quiet", "[", 
    RowBox[{"Total", "[", 
     RowBox[{"RealAbs", "[", 
      RowBox[{
       RowBox[{"solverHelper2", "[", 
        RowBox[{"c0sh", ",", "points"}], "]"}], "[", 
       RowBox[{"[", "1", "]"}], "]"}], "]"}], "]"}], "]"}]}], ";"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.},
 CellChangeTimes->{
  3.795003823722966*^9, 3.7976778393891587`*^9, {3.7980508671726136`*^9, 
   3.7980508733502235`*^9}, 3.798051505420906*^9, {3.7989699762867794`*^9, 
   3.7989699788976526`*^9}, 3.79949307454843*^9, {3.9004956945943813`*^9, 
   3.90049569909838*^9}, 3.900596241277821*^9, {3.9005964741084433`*^9, 
   3.900596478588636*^9}, 3.9006411561478786`*^9, {3.90066697187146*^9, 
   3.900666972235709*^9}, 3.900734639771041*^9},
 CellLabel->"In[64]:=",ExpressionUUID->"6e8a8d3e-255e-4c88-a04c-48d545d01f1d"]
}, Closed]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{
   RowBox[{"scoreDynasty", "[", 
    RowBox[{"c0sh_", ",", "points_", ",", "dynasty_"}], "]"}], " ", "-", " ", 
   RowBox[{
   "a", " ", "score", " ", "determining", " ", "how", " ", "close", " ", 
    "the", " ", "initial", " ", "guess", " ", "of", " ", "consumption", " ", 
    "distributions", " ", "is", " ", "to", " ", "the", " ", "correct", " ", 
    "score", " ", "of", " ", "zero", " ", "for", " ", "a", " ", "specific", 
    " ", "dynasty"}]}], "*)"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10005.},
 CellChangeTimes->{{3.7950038196397038`*^9, 3.795003823722966*^9}, 
   3.79949307454843*^9, {3.900641160287438*^9, 3.9006411738271646`*^9}, {
   3.9030698007118063`*^9, 3.903069821093258*^9}},
 CellLabel->"In[65]:=",ExpressionUUID->"3ed22e86-6983-4e9c-9857-6b75f15f81a2"],

Cell[BoxData[
 RowBox[{
  RowBox[{
   RowBox[{"scoreDynasty", "[", 
    RowBox[{"c0sh_", ",", "points_", ",", "dynasty_"}], "]"}], ":=", 
   RowBox[{
    RowBox[{"scoreDynasty", "[", 
     RowBox[{"c0sh", ",", "points", ",", "dynasty"}], "]"}], "=", 
    RowBox[{"Quiet", "[", 
     RowBox[{"RealAbs", "[", 
      RowBox[{
       RowBox[{"solverHelper2", "[", 
        RowBox[{"c0sh", ",", "points"}], "]"}], "[", 
       RowBox[{"[", 
        RowBox[{"1", ",", "dynasty"}], "]"}], "]"}], "]"}], "]"}]}]}], 
  ";"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10005.},
 CellChangeTimes->{
  3.795003823722966*^9, 3.7976778393891587`*^9, {3.7980508671726136`*^9, 
   3.7980508733502235`*^9}, 3.798051505420906*^9, {3.7989699762867794`*^9, 
   3.7989699788976526`*^9}, 3.79949307454843*^9, {3.9004956945943813`*^9, 
   3.90049569909838*^9}, 3.900596241277821*^9, {3.9005964741084433`*^9, 
   3.900596478588636*^9}, {3.900641169205822*^9, 3.9006412181254463`*^9}, {
   3.900666988372466*^9, 3.900666988672138*^9}},
 CellLabel->"In[66]:=",ExpressionUUID->"abedbc39-d76d-4985-a800-b0b83907abdd"]
}, Closed]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{
   RowBox[{
    RowBox[{
     RowBox[{
      RowBox[{"mechFindInitialC0pct", "[", 
       RowBox[{
       "C0sharesVector_", ",", "ppVector_", ",", "TotalError_", ",", 
        "DynastyError_", ",", "pct_"}], "]"}], " ", "--"}], "--"}], "-", " ", 
    RowBox[{
    "This", " ", "Method", " ", "finds", " ", "the", " ", "initial", " ", 
     "distribution", " ", "of", " ", "consumptions", " ", "by", " ", 
     RowBox[{"dynasty", ".", " ", "It"}], " ", "works", " ", "by", " ", 
     "repeatedly", " ", "minimizing", " ", "the", " ", "error", " ", 
     "between", " ", "guess", " ", "and", " ", "implied", " ", "initial", " ",
      "consumption"}], " ", "-", " ", 
    RowBox[{"dynasty", " ", "by", " ", "dynasty"}], " ", "-", " ", 
    RowBox[{
    "until", " ", "the", " ", "total", " ", "error", " ", "falls", " ", 
     "below", " ", "some", " ", 
     RowBox[{"threshold", ".", "C0sharesVector"}], " ", "is", " ", "the", " ",
      "initial", " ", "guess", " ", "of", " ", "consumption"}]}], ",", " ", 
   RowBox[{"ppVector", " ", "is", " ", "the", " ", "points", " ", 
    RowBox[{"vector", ".", " ", "TotalError"}], " ", "is", " ", "the", " ", 
    "error", " ", "we", " ", "tolerate", " ", "for", " ", "the", " ", 
    "entire", " ", "solution", " ", "and", " ", "DynastyError", " ", "is", 
    " ", "the", " ", "dynasty", " ", "level", " ", "error", " ", "we", " ", 
    "are", " ", "willing", " ", "to", " ", 
    RowBox[{"tolerate", "."}]}]}], " ", "*)"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10004.},
 CellChangeTimes->{{3.7993218571334095`*^9, 3.7993218586827126`*^9}, 
   3.7993219859979706`*^9, {3.7993221001669445`*^9, 3.799322100306079*^9}, {
   3.799322655880896*^9, 3.799322762945964*^9}, {3.79932279993637*^9, 
   3.7993228467615347`*^9}, {3.799324125935873*^9, 3.7993241328180313`*^9}, {
   3.8031969332847204`*^9, 3.803196937625266*^9}, 3.903069831904908*^9},
 CellLabel->"In[67]:=",ExpressionUUID->"18f86bc5-2c3b-4620-888e-cef65b809138"],

Cell[BoxData[
 RowBox[{
  RowBox[{
   RowBox[{"mechFindInitialC0pct", "[", 
    RowBox[{
    "C0sharesVector_", ",", "ppVector_", ",", "TotalError_", ",", " ", 
     "DynastyError_", ",", "pct_"}], "]"}], ":=", "\[IndentingNewLine]", 
   RowBox[{"Block", "[", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{
       RowBox[{"pVectorAll", "=", "ppVector"}], ",", 
       RowBox[{"C0sharesvec", "=", "C0sharesVector"}], ",", 
       RowBox[{"pc", "=", "pct"}], ",", 
       RowBox[{"ttler", "=", "TotalError"}], ",", 
       RowBox[{"dyner", "=", "DynastyError"}], ",", "\[IndentingNewLine]", 
       "ss", ",", "dynasty", ",", "dynastyN", ",", "lb", ",", "ub", ",", 
       "acc", ",", "i"}], "\[IndentingNewLine]", "}"}], ",", 
     "\[IndentingNewLine]", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"dynastyN", "=", 
       RowBox[{"Length", "[", 
        RowBox[{"pVectorAll", "[", 
         RowBox[{"[", 
          RowBox[{"1", ",", "2"}], "]"}], "]"}], "]"}]}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{"ss", "=", 
       RowBox[{"score", "[", 
        RowBox[{"C0sharesvec", ",", "pVectorAll"}], "]"}]}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{"PrintTemporary", "[", 
       RowBox[{"\"\<score: \>\"", ",", 
        RowBox[{"1.0", "*", "ss"}]}], "]"}], ";", "\[IndentingNewLine]", 
      RowBox[{"While", "[", 
       RowBox[{
        RowBox[{"ss", ">", "ttler"}], ",", "\[IndentingNewLine]", 
        "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"For", "[", 
          RowBox[{
           RowBox[{"dynasty", "=", "dynastyN"}], ",", 
           RowBox[{"dynasty", "\[GreaterEqual]", "1"}], ",", 
           RowBox[{"dynasty", "--"}], ",", "\[IndentingNewLine]", 
           RowBox[{"(*", 
            RowBox[{
             RowBox[{"lb", "=", 
              RowBox[{"SetPrecision", "[", 
               RowBox[{
                RowBox[{
                 RowBox[{"C0sharesvec", "[", 
                  RowBox[{"[", "dynasty", "]"}], "]"}], "*", 
                 RowBox[{"(", 
                  RowBox[{"1", "-", "pc"}], ")"}]}], ",", "acc"}], "]"}]}], 
             ";", "\[IndentingNewLine]", 
             RowBox[{"ub", "=", 
              RowBox[{"SetPrecision", "[", 
               RowBox[{
                RowBox[{
                 RowBox[{"C0sharesvec", "[", 
                  RowBox[{"[", "dynasty", "]"}], "]"}], "*", 
                 RowBox[{"(", 
                  RowBox[{"1", "+", "pc"}], ")"}]}], ",", "acc"}], "]"}]}], 
             ";"}], "*)"}], "\[IndentingNewLine]", 
           RowBox[{
            RowBox[{"PrintTemporary", "[", 
             RowBox[{"C0sharesvec", "*", "1.0"}], "]"}], ";", 
            "\[IndentingNewLine]", 
            RowBox[{"PrintTemporary", "[", "dynasty", "]"}], ";", 
            "\[IndentingNewLine]", 
            RowBox[{"lb", "=", 
             RowBox[{
              RowBox[{"C0sharesvec", "[", 
               RowBox[{"[", "dynasty", "]"}], "]"}], "*", 
              RowBox[{"(", 
               RowBox[{"1", "-", "pc"}], ")"}]}]}], ";", 
            "\[IndentingNewLine]", 
            RowBox[{"ub", "=", 
             RowBox[{
              RowBox[{"C0sharesvec", "[", 
               RowBox[{"[", "dynasty", "]"}], "]"}], "*", 
              RowBox[{"(", 
               RowBox[{"1", "+", "pc"}], ")"}]}]}], ";", 
            "\[IndentingNewLine]", 
            RowBox[{"C0sharesvec", "=", 
             RowBox[{"HelperMechFindInitialC0", "[", 
              RowBox[{
              "lb", ",", "ub", ",", "dynasty", ",", "C0sharesvec", ",", 
               "pVectorAll", ",", "dyner"}], "]"}]}], ";"}]}], 
          "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", 
         RowBox[{"ss", "=", 
          RowBox[{"score", "[", 
           RowBox[{"C0sharesvec", ",", "pVectorAll"}], "]"}]}], ";", 
         "\[IndentingNewLine]", 
         RowBox[{"PrintTemporary", "[", 
          RowBox[{"\"\<score: \>\"", ",", 
           RowBox[{"1.0", "*", "ss"}]}], "]"}], ";"}]}], 
       "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"Return", "[", "C0sharesvec", "]"}], ";"}]}], 
    "\[IndentingNewLine]", "\[IndentingNewLine]", "]"}]}], ";"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10004.},
 CellChangeTimes->{{3.9001454708882847`*^9, 3.900145475737095*^9}, {
   3.9001482746760893`*^9, 3.900148298526965*^9}, {3.900148655718403*^9, 
   3.900148655946472*^9}, {3.900149038362431*^9, 3.900149040961828*^9}, {
   3.900149902478441*^9, 3.9001499183691607`*^9}, {3.901207634022678*^9, 
   3.901207638771194*^9}, {3.9012076749750566`*^9, 3.9012077192242937`*^9}, {
   3.90125122197867*^9, 3.901251222199942*^9}, 3.903069840031372*^9},
 CellLabel->"In[68]:=",ExpressionUUID->"6d20dfc5-7ea8-40b2-98ec-60de1273267d"]
}, Closed]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{
   RowBox[{
    RowBox[{
     RowBox[{"adjustInitCons", "[", 
      RowBox[{"x_", ",", "pos_", ",", "c0DistAfterCol_"}], "]"}], ".", " ", 
     RowBox[{"--", 
      RowBox[{"--", 
       RowBox[{"-", " ", "This"}]}]}]}], " ", "Method", " ", "Adjusts", " ", 
    "the", " ", "initial", " ", "consumption", " ", "share", " ", "vector", 
    " ", "at", " ", "position", " ", "pos"}], ",", " ", 
   RowBox[{
   "by", " ", "replacing", " ", "the", " ", "pos", " ", "entry", " ", "by", 
    " ", "x", " ", "and", " ", "adjusting", " ", "all", " ", "remaining", " ",
     "entries", " ", "so", " ", "that", " ", "vector", " ", "still", " ", 
    "adds", " ", "up", " ", "to", " ", "1"}]}], "*)"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10002.},
 CellChangeTimes->{{3.798997477187857*^9, 3.798997540061536*^9}, {
   3.798997656467144*^9, 3.798997657955463*^9}, 3.7990593367358565`*^9, {
   3.7993240986328583`*^9, 3.7993241049344625`*^9}, {3.903069850830799*^9, 
   3.903069851184373*^9}},
 CellLabel->"In[69]:=",ExpressionUUID->"fc26ef9d-123d-47e0-8941-9fb13070e900"],

Cell[BoxData[
 RowBox[{
  RowBox[{
   RowBox[{"adjustInitCons", "[", 
    RowBox[{"x_", ",", "pos_", ",", "c0DistAfterCol_"}], "]"}], ":=", 
   RowBox[{"ReplacePart", "[", 
    RowBox[{
     RowBox[{
      RowBox[{"(", 
       RowBox[{"1", "-", "x"}], ")"}], "*", 
      RowBox[{"SetPrecision", "[", 
       RowBox[{
        FractionBox["c0DistAfterCol", 
         RowBox[{"1", "-", 
          RowBox[{"c0DistAfterCol", "[", 
           RowBox[{"[", "pos", "]"}], "]"}]}]], ",", "2000"}], "]"}]}], ",", 
     RowBox[{"{", 
      RowBox[{"pos", "\[Rule]", "x"}], "}"}]}], "]"}]}], ";"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10002.},
 CellChangeTimes->{{3.7989974411608243`*^9, 3.798997475987136*^9}, 
   3.798997525564763*^9, 3.7990593367358565`*^9, {3.7990668539357395`*^9, 
   3.7990668555921535`*^9}, 3.7990675259015274`*^9, {3.79907043563128*^9, 
   3.799070436243194*^9}, 3.7993241049344625`*^9, {3.900472404721653*^9, 
   3.900472438641068*^9}, 3.9004727624891863`*^9, {3.900493867478427*^9, 
   3.900493871126789*^9}, {3.900493904441944*^9, 3.9004939869592047`*^9}, {
   3.900494030287545*^9, 3.90049403427903*^9}, {3.900729127926978*^9, 
   3.900729129651873*^9}, 3.9007291660033493`*^9},
 CellLabel->"In[70]:=",ExpressionUUID->"d4dc1cd7-599e-4512-8bf8-6e93e8d0a2e6"]
}, Closed]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{
   RowBox[{
    RowBox[{
     RowBox[{
      RowBox[{"HelperMechFindInitialC0", "[", 
       RowBox[{
       "lowbd_", ",", "upbd_", ",", "dyn_", ",", "C0sharesVector_", ",", 
        "ppVector_", ",", "DynastyError_"}], "]"}], " ", "--"}], "--"}], 
    "--"}], "-", " ", 
   RowBox[{
   "This", " ", "method", " ", "is", " ", "a", " ", "helper", " ", "method", 
    " ", "to", " ", 
    RowBox[{
     RowBox[{"mechFindInitialC0", "[", 
      RowBox[{
      "C0sharesVector_", ",", "ppVector_", ",", "TotalError_", ",", 
       "DynastyError_"}], "]"}], ".", " ", "It"}], " ", "minimizes", " ", 
    "the", " ", "error", " ", "for", " ", "one", " ", "dynasty", " ", 
    RowBox[{"only", "."}]}]}], " ", "*)"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10003.},
 CellChangeTimes->{{3.7991436190486865`*^9, 3.799143624408559*^9}, {
   3.7993218634036922`*^9, 3.7993218767361965`*^9}, {3.7993219231468153`*^9, 
   3.7993219392367687`*^9}, {3.799322767334841*^9, 3.799322792545657*^9}, {
   3.7993241112360067`*^9, 3.799324120546436*^9}, 
   3.9030698652433653`*^9},ExpressionUUID->"2d7e905b-ff5b-4b4c-945e-\
04fb7e4a62da"],

Cell[BoxData[
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"HelperMechFindInitialC0", "[", 
     RowBox[{
     "lowbd_", ",", "upbd_", ",", "dyn_", ",", "C0sharesVector_", ",", 
      "ppVector_", ",", "DynastyError_"}], "]"}], ":=", "\[IndentingNewLine]", 
    RowBox[{"Block", "[", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{
        RowBox[{"pVectorAll", "=", "ppVector"}], ",", 
        RowBox[{"C0sharesvec", "=", "C0sharesVector"}], ",", 
        RowBox[{"lb", "=", "lowbd"}], ",", 
        RowBox[{"ub", "=", "upbd"}], ",", 
        RowBox[{"dyner", "=", "DynastyError"}], ",", 
        RowBox[{"dynasty", "=", "dyn"}], ",", "\[IndentingNewLine]", "delta", 
        ",", "ex", ",", "datatemp", ",", "data", ",", "minpos", ",", 
        "dynastyScore", ",", "density", ",", "error", ",", "breakcondition", 
        ",", "currentscore", ",", "isLowestscore", ",", "acc", ",", "temp", 
        ",", "test", ",", "C0sharesvecold", ",", " ", "counter", ",", "i"}], 
       "\[IndentingNewLine]", "}"}], ",", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"density", "=", 
        RowBox[{"$ProcessorCount", "-", "1"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{"error", "=", "dyner"}], ";", "\[IndentingNewLine]", 
       RowBox[{"acc", "=", 
        RowBox[{"pVectorAll", "[", 
         RowBox[{"[", 
          RowBox[{"15", ",", "2"}], "]"}], "]"}]}], ";", " ", 
       RowBox[{"(*", 
        RowBox[{"Accuracy", "/", "precision"}], "*)"}], "\[IndentingNewLine]",
        "\[IndentingNewLine]", 
       RowBox[{"delta", "=", 
        FractionBox[
         RowBox[{"SetAccuracy", "[", 
          RowBox[{
           RowBox[{"ub", "-", "lb"}], ",", "acc"}], "]"}], 
         RowBox[{"SetAccuracy", "[", 
          RowBox[{"density", ",", "acc"}], "]"}]]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"ex", "=", 
        RowBox[{"Table", "[", 
         RowBox[{"x", ",", 
          RowBox[{"{", 
           RowBox[{"x", ",", "lb", ",", "ub", ",", "delta"}], "}"}]}], 
         "]"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{"datatemp", "=", 
        RowBox[{"ParallelMap", "[", 
         RowBox[{
          RowBox[{
           RowBox[{
            RowBox[{"Quiet", "[", 
             RowBox[{"solverHelper2", "[", 
              RowBox[{
               RowBox[{"adjustInitCons", "[", 
                RowBox[{"#", ",", "dynasty", ",", "C0sharesvec"}], "]"}], ",",
                "pVectorAll"}], "]"}], "]"}], "[", 
            RowBox[{"[", "1", "]"}], "]"}], "&"}], ",", "ex"}], "]"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"data", "=", 
        RowBox[{"1.0", "*", 
         RowBox[{"Abs", "[", 
          RowBox[{"datatemp", "[", 
           RowBox[{"[", 
            RowBox[{"All", ",", "dynasty"}], "]"}], "]"}], "]"}]}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"minpos", "=", 
        RowBox[{
         RowBox[{"Ordering", "[", 
          RowBox[{"data", ",", "1"}], "]"}], "[", 
         RowBox[{"[", "1", "]"}], "]"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{"dynastyScore", "=", 
        RowBox[{
         RowBox[{"RealAbs", "[", 
          RowBox[{"datatemp", "[", 
           RowBox[{"[", "minpos", "]"}], "]"}], "]"}], "[", 
         RowBox[{"[", "dynasty", "]"}], "]"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{"temp", "=", 
        RowBox[{"PrintTemporary", "[", 
         RowBox[{"\"\< Dynasty Score=\>\"", ",", 
          RowBox[{"dynastyScore", "*", "1.0"}], ",", "\"\< lb=\>\"", ",", 
          RowBox[{"1.0", "*", "lb"}], ",", "\"\< ub=\>\"", ",", 
          RowBox[{"1.0", "*", "ub"}], ",", "\"\< minpos=\>\"", ",", "minpos", 
          ",", "\"\< score=\>\"", ",", 
          RowBox[{"1.0", "*", 
           RowBox[{"Total", "[", 
            RowBox[{"Abs", "[", 
             RowBox[{"datatemp", "[", 
              RowBox[{"[", "minpos", "]"}], "]"}], "]"}], "]"}]}]}], "]"}]}], 
       ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{"counter", "=", "0"}], ";", "\[IndentingNewLine]", 
       "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{"breakcondition", "=", 
        RowBox[{
         RowBox[{"(", 
          RowBox[{"!", 
           RowBox[{"(", 
            RowBox[{
             RowBox[{"(", 
              RowBox[{
               RowBox[{"(", 
                RowBox[{
                 FractionBox["ub", "lb"], "-", "1"}], ")"}], "<", 
               SuperscriptBox["10", 
                RowBox[{"-", "6"}]]}], ")"}], "&&", 
             RowBox[{"(", 
              RowBox[{"dynastyScore", ">", 
               SuperscriptBox["10", 
                RowBox[{"-", "7"}]]}], ")"}]}], ")"}]}], ")"}], "&&", 
         RowBox[{
          RowBox[{"Im", "[", 
           RowBox[{
            RowBox[{"datatemp", "[", 
             RowBox[{"[", "minpos", "]"}], "]"}], "[", 
            RowBox[{"[", "dynasty", "]"}], "]"}], "]"}], "==", "0"}]}]}], ";",
        "\[IndentingNewLine]", 
       RowBox[{"(*", 
        RowBox[{
         RowBox[{"isLowestscore", "=", "True"}], ";"}], "*)"}], 
       RowBox[{"(*", 
        RowBox[{"&&", "isLowestscore"}], "*)"}], "\[IndentingNewLine]", 
       RowBox[{"While", "[", 
        RowBox[{
         RowBox[{
          RowBox[{"(", 
           RowBox[{"dynastyScore", ">", "error"}], ")"}], "&&", 
          RowBox[{"ub", "<", "0.99"}], "&&", "breakcondition"}], ",", 
         "\[IndentingNewLine]", "\[IndentingNewLine]", 
         RowBox[{
          RowBox[{"If", "[", 
           RowBox[{
            RowBox[{"minpos", "\[Equal]", "1"}], ",", "\[IndentingNewLine]", 
            RowBox[{
             RowBox[{"lb", "=", 
              FractionBox["lb", "10.0"]}], ";", 
             RowBox[{"ub", "=", 
              RowBox[{"ex", "[", 
               RowBox[{"[", 
                RowBox[{"minpos", "+", "1"}], "]"}], "]"}]}], ";", 
             "\[IndentingNewLine]", 
             RowBox[{"(*", 
              RowBox[{
               RowBox[{"lb", "=", 
                FractionBox["lb", "10.0"]}], ";", 
               RowBox[{"ub", "=", 
                RowBox[{"ex", "[", 
                 RowBox[{"[", "minpos", "]"}], "]"}]}], ";"}], "*)"}], 
             "\[IndentingNewLine]", 
             RowBox[{"counter", "++"}], ";"}], "\[IndentingNewLine]", 
            RowBox[{"(*", 
             RowBox[{
              RowBox[{"If", "[", 
               RowBox[{
                RowBox[{"counter", ">", "10"}], ",", 
                RowBox[{
                 RowBox[{"breakcondition", "=", "False"}], ";", 
                 RowBox[{"Break", "[", "]"}], ";"}]}], "]"}], ";"}], "*)"}], 
            "\[IndentingNewLine]", "\[IndentingNewLine]", 
            "\[IndentingNewLine]", 
            RowBox[{"(*", "\[IndentingNewLine]", 
             RowBox[{
              RowBox[{"C0sharesvec", "=", 
               RowBox[{"adjustInitCons", "[", 
                RowBox[{
                 RowBox[{"ex", "[", 
                  RowBox[{"[", 
                   RowBox[{"minpos", "+", "1"}], "]"}], "]"}], ",", "dynasty",
                  ",", "C0sharesvec"}], "]"}]}], ";", "\[IndentingNewLine]", 
              RowBox[{"test", "=", 
               RowBox[{"solverHelper2", "[", 
                RowBox[{"C0sharesvec", ",", "pVectorAll"}], "]"}]}], ";", 
              "\[IndentingNewLine]", 
              RowBox[{"pVectorAll", "=", 
               RowBox[{"Join", "[", 
                RowBox[{
                 RowBox[{"Most", "[", "pVectorAll", "]"}], ",", 
                 RowBox[{"{", 
                  RowBox[{"initpointsx", "->", 
                   RowBox[{"Join", "[", 
                    RowBox[{
                    RowBox[{"test", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "All", ",", "7", ",", "1"}], "]"}], 
                    "]"}], ",", 
                    RowBox[{"test", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "All", ",", "6", ",", "1"}], "]"}], 
                    "]"}]}], "]"}]}], "}"}]}], "]"}]}], ";"}], 
             "\[IndentingNewLine]", "\[IndentingNewLine]", "*)"}], 
            "\[IndentingNewLine]", ",", "\[IndentingNewLine]", 
            "\[IndentingNewLine]", 
            RowBox[{
             RowBox[{"If", "[", 
              RowBox[{
               RowBox[{"minpos", "\[Equal]", 
                RowBox[{"Length", "[", "ex", "]"}]}], ",", 
               "\[IndentingNewLine]", 
               RowBox[{
                RowBox[{"lb", "=", 
                 RowBox[{"ex", "[", 
                  RowBox[{"[", 
                   RowBox[{"minpos", "-", "1"}], "]"}], "]"}]}], ";", 
                RowBox[{"ub", "=", 
                 RowBox[{"ub", "+", 
                  FractionBox[
                   RowBox[{"1", "-", "ub"}], "2.0"]}]}], ";"}], ",", 
               "\[IndentingNewLine]", 
               RowBox[{"(*", 
                RowBox[{
                 RowBox[{
                  RowBox[{"lb", "=", 
                   RowBox[{"ex", "[", 
                    RowBox[{"[", "minpos", "]"}], "]"}]}], ";", 
                  RowBox[{"ub", "=", 
                   RowBox[{"ub", "+", 
                    FractionBox[
                    RowBox[{"1", "-", "ub"}], "2.0"]}]}], ";"}], ","}], 
                "*)"}], "\[IndentingNewLine]", 
               RowBox[{
                RowBox[{"lb", "=", 
                 RowBox[{"ex", "[", 
                  RowBox[{"[", 
                   RowBox[{"minpos", "-", "1"}], "]"}], "]"}]}], ";", 
                "\[IndentingNewLine]", 
                RowBox[{"ub", "=", 
                 RowBox[{"ex", "[", 
                  RowBox[{"[", 
                   RowBox[{"minpos", "+", "1"}], "]"}], "]"}]}], ";"}]}], 
              "\[IndentingNewLine]", "]"}], ";"}]}], "\[IndentingNewLine]", 
           "]"}], ";", "\[IndentingNewLine]", 
          RowBox[{"delta", "=", 
           FractionBox[
            RowBox[{"SetAccuracy", "[", 
             RowBox[{
              RowBox[{"ub", "-", "lb"}], ",", "acc"}], "]"}], 
            RowBox[{"SetAccuracy", "[", 
             RowBox[{"density", ",", "acc"}], "]"}]]}], ";", 
          "\[IndentingNewLine]", 
          RowBox[{"ex", "=", 
           RowBox[{"Table", "[", 
            RowBox[{"x", ",", 
             RowBox[{"{", 
              RowBox[{"x", ",", "lb", ",", "ub", ",", "delta"}], "}"}]}], 
            "]"}]}], ";", "\[IndentingNewLine]", 
          RowBox[{"datatemp", "=", 
           RowBox[{"ParallelMap", "[", 
            RowBox[{
             RowBox[{
              RowBox[{
               RowBox[{"Quiet", "[", 
                RowBox[{"solverHelper2", "[", 
                 RowBox[{
                  RowBox[{"adjustInitCons", "[", 
                   RowBox[{"#", ",", "dynasty", ",", "C0sharesvec"}], "]"}], 
                  ",", "pVectorAll"}], "]"}], "]"}], "[", 
               RowBox[{"[", "1", "]"}], "]"}], "&"}], ",", "ex"}], "]"}]}], 
          ";", "\[IndentingNewLine]", 
          RowBox[{"data", "=", 
           RowBox[{"1.0", "*", 
            RowBox[{"Abs", "[", 
             RowBox[{"datatemp", "[", 
              RowBox[{"[", 
               RowBox[{"All", ",", "dynasty"}], "]"}], "]"}], "]"}]}]}], ";", 
          "\[IndentingNewLine]", 
          RowBox[{"minpos", "=", 
           RowBox[{
            RowBox[{"Ordering", "[", 
             RowBox[{"data", ",", "1"}], "]"}], "[", 
            RowBox[{"[", "1", "]"}], "]"}]}], ";", "\[IndentingNewLine]", 
          RowBox[{"dynastyScore", "=", 
           RowBox[{
            RowBox[{"RealAbs", "[", 
             RowBox[{"datatemp", "[", 
              RowBox[{"[", "minpos", "]"}], "]"}], "]"}], "[", 
            RowBox[{"[", "dynasty", "]"}], "]"}]}], ";", 
          "\[IndentingNewLine]", "\[IndentingNewLine]", 
          RowBox[{"breakcondition", "=", 
           RowBox[{
            RowBox[{"(", 
             RowBox[{"!", 
              RowBox[{"(", 
               RowBox[{
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{"(", 
                   RowBox[{
                    FractionBox["ub", "lb"], "-", "1"}], ")"}], "<", 
                  SuperscriptBox["10", 
                   RowBox[{"-", "6"}]]}], ")"}], "&&", 
                RowBox[{"(", 
                 RowBox[{"dynastyScore", ">", 
                  SuperscriptBox["10", 
                   RowBox[{"-", "7"}]]}], ")"}]}], ")"}]}], ")"}], "&&", 
            RowBox[{
             RowBox[{"Im", "[", 
              RowBox[{
               RowBox[{"datatemp", "[", 
                RowBox[{"[", "minpos", "]"}], "]"}], "[", 
               RowBox[{"[", "dynasty", "]"}], "]"}], "]"}], "==", "0"}]}]}], 
          ";", 
          RowBox[{"(*", 
           RowBox[{
            RowBox[{"If", "[", 
             RowBox[{
              RowBox[{
               RowBox[{"Total", "[", 
                RowBox[{"Abs", "[", 
                 RowBox[{"datatemp", "[", 
                  RowBox[{"[", "minpos", "]"}], "]"}], "]"}], "]"}], "<", 
               "currentscore"}], ",", 
              RowBox[{
               RowBox[{"isLowestscore", "=", "False"}], ";"}]}], "]"}], ";"}],
            "*)"}], "\[IndentingNewLine]", "\[IndentingNewLine]", 
          RowBox[{"If", "[", 
           RowBox[{
            RowBox[{"breakcondition", "\[Equal]", "False"}], ",", 
            RowBox[{
             RowBox[{"PrintTemporary", "[", 
              RowBox[{"\"\< Dynasty Score=\>\"", ",", 
               RowBox[{"dynastyScore", "*", "1.0"}], ",", "\"\< lb=\>\"", ",", 
               RowBox[{"1.0", "*", "lb"}], ",", "\"\< ub=\>\"", ",", 
               RowBox[{"1.0", "*", "ub"}], ",", "\"\< minpos=\>\"", ",", 
               RowBox[{"minpos", "\"\< score=\>\""}], ",", 
               RowBox[{"1.0", "*", 
                RowBox[{"Total", "[", 
                 RowBox[{"Abs", "[", 
                  RowBox[{"datatemp", "[", 
                   RowBox[{"[", "minpos", "]"}], "]"}], "]"}], "]"}]}], ",", 
               "\"\< bc:\>\"", ",", "breakcondition"}], "]"}], ";"}]}], 
           "\[IndentingNewLine]", "\[IndentingNewLine]", "]"}], ";", 
          "\[IndentingNewLine]", 
          RowBox[{"NotebookDelete", "[", "temp", "]"}], ";", 
          "\[IndentingNewLine]", 
          RowBox[{"temp", "=", 
           RowBox[{"PrintTemporary", "[", 
            RowBox[{"\"\< Dynasty Score=\>\"", ",", 
             RowBox[{"dynastyScore", "*", "1.0"}], ",", "\"\< lb=\>\"", ",", 
             RowBox[{"1.0", "*", "lb"}], ",", "\"\< ub=\>\"", ",", 
             RowBox[{"1.0", "*", "ub"}], ",", "\"\< minpos=\>\"", ",", 
             "minpos", ",", "\"\< score=\>\"", ",", 
             RowBox[{"1.0", "*", 
              RowBox[{"Total", "[", 
               RowBox[{"Abs", "[", 
                RowBox[{"datatemp", "[", 
                 RowBox[{"[", "minpos", "]"}], "]"}], "]"}], "]"}]}]}], 
            "]"}]}], ";"}]}], "\[IndentingNewLine]", "\[IndentingNewLine]", 
        "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", 
       "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{"If", "[", 
        RowBox[{
         RowBox[{"(", 
          RowBox[{
           RowBox[{"ub", "<", "0.99"}], "&&", 
           RowBox[{"(", "breakcondition", ")"}]}], ")"}], ",", 
         "\[IndentingNewLine]", "\[IndentingNewLine]", 
         RowBox[{
          RowBox[{"C0sharesvec", "=", 
           RowBox[{"adjustInitCons", "[", 
            RowBox[{
             RowBox[{"ex", "[", 
              RowBox[{"[", "minpos", "]"}], "]"}], ",", "dynasty", ",", 
             "C0sharesvec"}], "]"}]}], ";"}]}], "\[IndentingNewLine]", 
        "\[IndentingNewLine]", "\[IndentingNewLine]", "]"}], ";", 
       "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{"Return", "[", "C0sharesvec", "]"}], ";"}]}], 
     "\[IndentingNewLine]", "]"}]}], ";"}], "\[IndentingNewLine]"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10003.},
 CellChangeTimes->{{3.7990762784563646`*^9, 3.79907629193554*^9}, {
   3.799076333279166*^9, 3.799076467098605*^9}, {3.7990765856897*^9, 
   3.7990766172245483`*^9}, {3.7990766958230963`*^9, 3.799076699050777*^9}, {
   3.7990767671143775`*^9, 3.7990767831374025`*^9}, {3.799076847238909*^9, 
   3.7990768788774085`*^9}, 3.7990769238041067`*^9, {3.799078298063733*^9, 
   3.7990783174216833`*^9}, 3.799143587170724*^9, 3.799143624408559*^9, {
   3.7991443096595764`*^9, 3.7991443450226545`*^9}, {3.799144393387095*^9, 
   3.7991443945278864`*^9}, {3.799149062802573*^9, 3.7991490652716475`*^9}, {
   3.7991550395346994`*^9, 3.7991550397690926`*^9}, {3.799163050791812*^9, 
   3.799163051323176*^9}, {3.7991665193608627`*^9, 3.7991665214548473`*^9}, {
   3.7992282467774677`*^9, 3.799228247840087*^9}, {3.7992364435750885`*^9, 
   3.799236446262872*^9}, {3.7992368950625963`*^9, 3.7992369280194206`*^9}, {
   3.7992373699303093`*^9, 3.7992374210607204`*^9}, {3.799237781989544*^9, 
   3.799237789786744*^9}, {3.7992487223868737`*^9, 3.7992487299188237`*^9}, {
   3.7992532533749213`*^9, 3.799253253656227*^9}, {3.7992756662504835`*^9, 
   3.799275668532048*^9}, 3.7993218837947197`*^9, {3.799321942643859*^9, 
   3.799321977286044*^9}, 3.799324120546436*^9, {3.7993297504653273`*^9, 
   3.79932975054346*^9}, {3.7993305596282234`*^9, 3.799330630229429*^9}, {
   3.799340171659392*^9, 3.7993401782226706`*^9}, {3.799422562744943*^9, 
   3.7994225669329133`*^9}, {3.799423419853402*^9, 3.799423422978727*^9}, {
   3.799424819751415*^9, 3.7994248318307796`*^9}, 3.799424947892465*^9, {
   3.799428434262222*^9, 3.799428465968088*^9}, {3.7994286552697954`*^9, 
   3.799428724776701*^9}, {3.7994295907584023`*^9, 3.7994295912272053`*^9}, {
   3.799436088108787*^9, 3.799436104641573*^9}, {3.7994446056252217`*^9, 
   3.799444615345745*^9}, {3.799492882558585*^9, 3.7994928871683283`*^9}, {
   3.7994929275356183`*^9, 3.799492937255146*^9}, {3.79949322684383*^9, 
   3.7994932393606186`*^9}, {3.7994933257592707`*^9, 
   3.7994933260717993`*^9}, {3.7994945810498185`*^9, 
   3.7994945910977306`*^9}, {3.799494705050288*^9, 3.7994947065348105`*^9}, {
   3.799494771761249*^9, 3.7994948135170555`*^9}, {3.79957928174817*^9, 
   3.799579453313036*^9}, {3.799579519851265*^9, 3.799579640926462*^9}, {
   3.7995796824308147`*^9, 3.7995797087303376`*^9}, {3.7995797964418097`*^9, 
   3.799579874761586*^9}, {3.7995806094282303`*^9, 3.799580646947603*^9}, {
   3.7995807084174323`*^9, 3.799580720059233*^9}, {3.799595266395975*^9, 
   3.7995952701308403`*^9}, {3.7995955582269535`*^9, 3.79959556127417*^9}, {
   3.7995957524386177`*^9, 3.7995957543138285`*^9}, {3.799862913808667*^9, 
   3.799862927856925*^9}, {3.7998632698609257`*^9, 3.799863273970709*^9}, {
   3.8005122881545687`*^9, 3.8005122961711383`*^9}, {3.800513963790834*^9, 
   3.800513964243968*^9}, {3.804829436762888*^9, 3.80482946404541*^9}, {
   3.804829812628451*^9, 3.804829812669404*^9}, {3.809946159337021*^9, 
   3.809946169931567*^9}, {3.900145697557602*^9, 3.90014569844291*^9}, {
   3.90014588458007*^9, 3.9001458854608927`*^9}, {3.900148606036751*^9, 
   3.900148624826025*^9}, {3.900149612384481*^9, 3.9001496238527737`*^9}, 
   3.90047820518163*^9, 3.900478303891714*^9, {3.9004915487866793`*^9, 
   3.90049157536959*^9}, {3.900492214510623*^9, 3.900492219286401*^9}, {
   3.900492264997219*^9, 3.9004922687062387`*^9}, {3.9006536877471437`*^9, 
   3.900653715431601*^9}, {3.900653814057967*^9, 3.9006538400145903`*^9}, {
   3.9006539589582157`*^9, 3.900653959483727*^9}, {3.900654762610581*^9, 
   3.90065476607761*^9}, {3.900665383907399*^9, 3.900665385983315*^9}, {
   3.900665419711285*^9, 3.900665430597863*^9}, {3.900665486947544*^9, 
   3.9006655648213987`*^9}, {3.9006656043997583`*^9, 
   3.9006656404016027`*^9}, {3.9006671157071457`*^9, 3.90066719710233*^9}, {
   3.9006679809360247`*^9, 3.9006680233925323`*^9}, {3.900668972091587*^9, 
   3.9006689807435627`*^9}, {3.900684675319396*^9, 3.9006846754585*^9}, {
   3.900684711521405*^9, 3.900684732769465*^9}, {3.900684960122882*^9, 
   3.900685009397491*^9}, {3.900685375390049*^9, 3.900685375707571*^9}, {
   3.900685419127179*^9, 3.900685422462638*^9}, {3.9006854851392612`*^9, 
   3.9006854979923553`*^9}, {3.900729392741049*^9, 3.9007293929536467`*^9}, {
   3.90072996726235*^9, 3.900729968614834*^9}, {3.9007308668682947`*^9, 
   3.9007308686836433`*^9}, {3.901207522160047*^9, 3.9012075294148817`*^9}, {
   3.9012075906198187`*^9, 3.9012076065304737`*^9}, {3.901208038730995*^9, 
   3.901208040977497*^9}, {3.901251205272862*^9, 3.901251205512628*^9}, {
   3.903069872584861*^9, 
   3.903069884083436*^9}},ExpressionUUID->"640ec9fb-161a-4cde-92e4-\
fe6aa0d8b08d"]
}, Closed]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{"adjustSumToOneProportionally", " ", "-", " ", 
   RowBox[{
   "adjust", " ", "vaues", " ", "in", " ", "a", " ", "table", " ", 
    "proporitonatly", " ", "so", " ", "that", " ", "they", " ", "still", " ", 
    "add", " ", "up", " ", "to", " ", "one"}]}], "*)"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10004.},
 CellChangeTimes->{{3.901248011174055*^9, 3.901248014940043*^9}, {
  3.903069899349594*^9, 
  3.903069917631612*^9}},ExpressionUUID->"eef4fad9-3fb1-43db-a229-\
4a612112b773"],

Cell[BoxData[
 RowBox[{
  RowBox[{
   RowBox[{"adjustSumToOneProportionally", "[", "list_", "]"}], ":=", 
   RowBox[{"Module", "[", 
    RowBox[{
     RowBox[{"{", "currentTotal", "}"}], ",", 
     RowBox[{
      RowBox[{"currentTotal", "=", 
       RowBox[{"Total", "[", "list", "]"}]}], ";", "\[IndentingNewLine]", 
      RowBox[{"list", "*", 
       RowBox[{"(", 
        RowBox[{"1", "/", "currentTotal"}], ")"}]}]}]}], "]"}]}], 
  "\n"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10004.},
 CellChangeTimes->{{3.900473308382526*^9, 3.900473308385844*^9}, 
   3.9005932265590887`*^9, 3.901248014940398*^9},
 CellLabel->"In[77]:=",ExpressionUUID->"a920aebb-9734-4bee-8bde-a425ca5d564c"]
}, Closed]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{
   RowBox[{"mutateAndSolve", "[", 
    RowBox[{
    "initpoints_", ",", "initanswer_", ",", "from_", ",", "to_", ",", 
     "nmutsize_", ",", "kmutsize_", ",", "coguesssize_", ",", "mutationtime_",
      ",", "totalerror_", ",", "dynastyerrorerror_", ",", "searchradius_"}], 
    "]"}], "\[IndentingNewLine]", "Open", " ", "for", " ", "description"}], 
  "\[IndentingNewLine]", "*)"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.},
 CellChangeTimes->{{3.9012495248373632`*^9, 3.901249769863204*^9}},
 CellLabel->"In[78]:=",ExpressionUUID->"b37660c9-50e6-4ede-a51d-9e263a95e3aa"],

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{
   RowBox[{
    RowBox[{"Mutate", " ", "an", " ", "answer"}], " ", "-", " ", 
    RowBox[{
    "initpoints", " ", "and", " ", "initanswer", " ", "are", " ", "the", " ", 
     "points", " ", "to", " ", "be", " ", 
     RowBox[{"mutated", ".", " ", "from"}], " ", "and", " ", "to", " ", 
     "refer", " ", "to", " ", "which", " ", "betas", " ", "are", " ", "to", 
     " ", "be", " ", 
     RowBox[{"mutated", ".", " ", "nmutesize"}], " ", "and", " ", "kmutesize",
      " ", "determine", " ", "how", " ", "large", " ", "the", " ", "mutation",
      " ", "is", " ", "and", " ", "coguesssize", " ", "guesses", " ", "how", 
     " ", "large", " ", "the", " ", "initial", " ", "consumption", " ", "of", 
     " ", "the", " ", "mutated", " ", "generation", " ", "is", " ", 
     RowBox[{
      RowBox[{"(", 
       RowBox[{
        RowBox[{"choosing", " ", "nmutsize"}], "=", 
        RowBox[{"kmutsize", "=", 
         RowBox[{
         "coguesssize", " ", "seems", " ", "to", " ", "give", " ", "the", " ",
           "correct", " ", "answer", " ", "right", " ", "off", " ", "the", 
          " ", "bat"}]}]}], ")"}], ".", " ", "mutationtime"}], " ", "says", 
     " ", "when", " ", "the", " ", "mutatino", " ", 
     RowBox[{"hits", ".", " ", "totalerror"}], " ", "is", " ", "the", " ", 
     "total", " ", "error", " ", "permisable", " ", "of", " ", "the", " ", 
     "entire", " ", "guess"}]}], ",", " ", 
   RowBox[{
   "whereas", " ", "dynastyerrorerror", " ", "is", " ", "the", " ", "largest",
     " ", "error", " ", "permisable", " ", "on", " ", "each", " ", 
    RowBox[{"dyansty", ".", " ", "searchradius"}], " ", "is", " ", "the", " ",
     "radius", " ", "around", " ", "the", " ", "initia", " ", "guess", " ", 
    "that", " ", "I", " ", "look", " ", "for", " ", "an", " ", "answer", " ", 
    "at", " ", "each", " ", 
    RowBox[{
    "iteration", ".", " ", "\[IndentingNewLine]", "\[IndentingNewLine]", 
     "The"}], " ", "code", " ", "essentially", " ", "take", " ", "an", " ", 
    "initial", " ", "guess", " ", "of", " ", "c0"}], ",", " ", 
   RowBox[{
   "then", " ", "dyansty", " ", "by", " ", "dyansty", " ", "minimizes", " ", 
    "the", " ", "dynaty", " ", "error", " ", "starting", " ", "from", " ", 
    "the", " ", "highest", " ", "to", " ", "the", " ", "lowest", " ", 
    "dynaty", " ", "and", " ", "repeats", " ", "until", " ", "the", " ", 
    "score", " ", "of", " ", "the", " ", "entire", " ", "solutionis", " ", 
    "below", " ", 
    RowBox[{"totalerror", "."}]}]}], "*)"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.},
 CellChangeTimes->{{3.9012497602992268`*^9, 3.90124976121667*^9}},
 CellLabel->"In[79]:=",ExpressionUUID->"a5f9cfc3-d73e-43d6-b5c6-a7fe9646af6a"],

Cell[BoxData[
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"mutateAndSolve", "[", 
     RowBox[{
     "initpoints_", ",", "initanswer_", ",", "from_", ",", "to_", ",", 
      "nmutsize_", ",", "kmutsize_", ",", "coguesssize_", ",", 
      "mutationtime_", ",", "totalerror_", ",", "dynastyerrorerror_", ",", 
      "searchradius_"}], "]"}], ":=", 
    RowBox[{"Module", "[", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{
       "pointsMutated", ",", "c0Vec", ",", "betavec", ",", "c0guess", ",", 
        "pointsMutatedss", ",", "cnew", ",", "scores", ",", "ipoints", ",", 
        "i"}], "}"}], ",", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"(*", 
       RowBox[{"Mutate", " ", "the", " ", "points"}], "*)"}], 
      "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"pointsMutated", "=", 
        RowBox[{"Mutate", "[", 
         RowBox[{
         "initpoints", ",", "from", ",", "to", ",", "nmutsize", ",", 
          "kmutsize"}], "]"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{"(*", 
        RowBox[{
        "Reduce", " ", "the", " ", "time", " ", "for", " ", "gn", " ", "and", 
         " ", "ktilde", " ", "initial", " ", "guesses"}], "*)"}], 
       RowBox[{
        RowBox[{"pointsMutated", "[", 
         RowBox[{"[", 
          RowBox[{"14", ",", "2"}], "]"}], "]"}], "=", 
        RowBox[{
         RowBox[{"pointsMutated", "[", 
          RowBox[{"[", 
           RowBox[{"14", ",", "2"}], "]"}], "]"}], "-", "mutationtime"}]}], 
       ";", "\[IndentingNewLine]", 
       RowBox[{"(*", 
        RowBox[{"Get", " ", "c0Vec", " ", "and", " ", "betavec"}], "*)"}], 
       "\[IndentingNewLine]", 
       RowBox[{"c0Vec", "=", 
        RowBox[{"initanswer", "[", 
         RowBox[{"[", 
          RowBox[{"2", ",", 
           RowBox[{"1", "+", "mutationtime"}], ",", "5", ",", "All", ",", 
           "2"}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{"betavec", "=", 
        RowBox[{"initpoints", "[", 
         RowBox[{"[", 
          RowBox[{"3", ",", "2"}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{"(*", 
        RowBox[{"Mutate", " ", "c0"}], "*)"}], "\[IndentingNewLine]", 
       RowBox[{"c0guess", "=", 
        RowBox[{"Mutatec0", "[", 
         RowBox[{
         "c0Vec", ",", "betavec", ",", "from", ",", "to", ",", 
          "coguesssize"}], "]"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{"(*", 
        RowBox[{
        "Combine", " ", "points", " ", "with", " ", "initial", " ", 
         "guesses"}], "*)"}], 
       RowBox[{"pointsMutatedss", "=", 
        RowBox[{"Join", "[", 
         RowBox[{"pointsMutated", ",", 
          RowBox[{"{", 
           RowBox[{"initpointsx", "->", 
            RowBox[{"Join", "[", 
             RowBox[{
              RowBox[{"initanswer", "[", 
               RowBox[{"[", 
                RowBox[{"2", ",", "All", ",", "6"}], "]"}], "]"}], ",", 
              RowBox[{"initanswer", "[", 
               RowBox[{"[", 
                RowBox[{"2", ",", "All", ",", "7"}], "]"}], "]"}]}], "]"}]}], 
           "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{"(*", 
        RowBox[{
        "Find", " ", "the", " ", "initial", " ", "C0", " ", "percentage"}], 
        "*)"}], 
       RowBox[{"cnew", "=", 
        RowBox[{"mechFindInitialC0pct", "[", 
         RowBox[{
         "c0guess", ",", "pointsMutatedss", ",", "totalerror", ",", 
          "dynastyerrorerror", ",", "searchradius"}], "]"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"(*", 
        RowBox[{
         RowBox[{"Solve", " ", "and", " ", "get", " ", "scores"}], ",", 
         "ipoints", ",", 
         RowBox[{"and", " ", "cnew"}]}], "*)"}], 
       RowBox[{
        RowBox[{"{", 
         RowBox[{"scores", ",", "ipoints", ",", "cnew"}], "}"}], "=", 
        RowBox[{"solverHelper2", "[", 
         RowBox[{"cnew", ",", "pointsMutatedss"}], "]"}]}], ";", 
       "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{"(*", 
        RowBox[{"Return", " ", "the", " ", "results"}], "*)"}], 
       "\[IndentingNewLine]", 
       RowBox[{"Clear", "[", "i", "]"}], ";", "\[IndentingNewLine]", 
       RowBox[{"{", 
        RowBox[{"scores", ",", "ipoints", ",", "cnew"}], "}"}]}]}], "]"}]}], 
   ";"}], "\n"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.},
 CellChangeTimes->{{3.9012493994123993`*^9, 3.901249434889943*^9}, 
   3.901249477773493*^9, 3.901249528114441*^9, {3.90125116159725*^9, 
   3.901251169684763*^9}, {3.901251277308487*^9, 3.90125128575975*^9}, {
   3.901251349500729*^9, 3.901251350933799*^9}},
 CellLabel->"In[80]:=",ExpressionUUID->"82964368-1f1f-4da4-a224-968e325c4451"]
}, Closed]],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{
   RowBox[{
    RowBox[{
     RowBox[{"combineMutants", "[", 
      RowBox[{"ans_", ",", "ansMutated_", ",", "mutationtime_"}], "]"}], ".", 
     " ", "The"}], " ", "module", " ", "processes", " ", "original", " ", 
    RowBox[{"(", "ans", ")"}], " ", "and", " ", "mutated", " ", 
    RowBox[{"(", "ansMutated", ")"}], " ", "population", " ", 
    RowBox[{"data", ".", "It"}], " ", "adjusts", " ", "mutation", " ", 
    "timings"}], ",", 
   RowBox[{"combines", " ", "both", " ", "datasets"}], ",", 
   RowBox[{
   "identifies", " ", "duplicates", " ", "in", " ", "mutation", " ", 
    "rates"}], ",", 
   RowBox[{
   "and", " ", "constructs", " ", "a", " ", "unified", " ", "time", " ", 
    "series", " ", "for", " ", "the", " ", "overall", " ", "and", " ", 
    "mutated", " ", 
    RowBox[{"populations", ".", "It"}], " ", "returns", " ", "the", " ", 
    "combined", " ", "time", " ", "series", " ", "for", " ", "general"}], ",",
    "mutated", ",", 
   RowBox[{"and", " ", "overall", " ", 
    RowBox[{"populations", "."}]}]}], "*)"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.},
 CellChangeTimes->{{3.900992926872107*^9, 3.900992927769463*^9}, {
   3.900992982980977*^9, 3.900992992672963*^9}, 3.902827371379918*^9},
 CellLabel->"In[81]:=",ExpressionUUID->"c26e07c8-1fa6-4f94-9856-f9b7d1ec1c48"],

Cell[BoxData[
 RowBox[{
  RowBox[{
   RowBox[{"combineMutants", "[", 
    RowBox[{"ans_", ",", "ansMutated_", ",", "mutationtime_"}], "]"}], ":=", 
   RowBox[{"Module", "[", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{
      "mutatedR", ",", "unmutatedR", ",", "combinedR", ",", "betas", ",", 
       "duplicates", ",", "posmutant", ",", "combinedpopmutant", ",", 
       "combinedPopMutant", ",", "combinedPop"}], "}"}], ",", 
     "\[IndentingNewLine]", "\[IndentingNewLine]", 
     RowBox[{"(*", 
      RowBox[{
      "Extract", " ", "mutated", " ", "and", " ", "unmutated", " ", "R", " ", 
       "values"}], "*)"}], "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"mutatedR", "=", 
       RowBox[{
        RowBox[{"ansMutated", "[", 
         RowBox[{"[", 
          RowBox[{"All", ",", "4"}], "]"}], "]"}], "[", 
        RowBox[{"[", 
         RowBox[{"All", ",", "1"}], "]"}], "]"}]}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{"unmutatedR", "=", 
       RowBox[{
        RowBox[{"ans", "[", 
         RowBox[{"[", 
          RowBox[{"All", ",", "4"}], "]"}], "]"}], "[", 
        RowBox[{"[", 
         RowBox[{"All", ",", "1"}], "]"}], "]"}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"(*", 
       RowBox[{
       "Adjust", " ", "the", " ", "time", " ", "for", " ", "mutated", " ", 
        "R", " ", "values"}], "*)"}], 
      RowBox[{
       RowBox[{"mutatedR", "[", 
        RowBox[{"[", 
         RowBox[{"All", ",", "1", ",", "2"}], "]"}], "]"}], "=", 
       RowBox[{
        RowBox[{"mutatedR", "[", 
         RowBox[{"[", 
          RowBox[{"All", ",", "1", ",", "2"}], "]"}], "]"}], "+", 
        "mutationtime"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"(*", 
       RowBox[{
       "Combine", " ", "mutated", " ", "and", " ", "unmutated", " ", "R", " ",
         "values"}], "*)"}], 
      RowBox[{"combinedR", "=", 
       RowBox[{"Join", "[", 
        RowBox[{
         RowBox[{"unmutatedR", "[", 
          RowBox[{"[", 
           RowBox[{"1", ";;", "mutationtime"}], "]"}], "]"}], ",", 
         "mutatedR"}], "]"}]}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"(*", 
       RowBox[{
       "Extract", " ", "betas", " ", "and", " ", "find", " ", "duplicates"}], 
       "*)"}], 
      RowBox[{"betas", "=", 
       RowBox[{"ansMutated", "[", 
        RowBox[{"[", 
         RowBox[{"1", ",", "3", ",", "All", ",", "2"}], "]"}], "]"}]}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{"duplicates", "=", 
       RowBox[{"Select", "[", 
        RowBox[{
         RowBox[{"Tally", "[", "betas", "]"}], ",", 
         RowBox[{
          RowBox[{
           RowBox[{"Last", "[", "#", "]"}], ">", "1"}], "&"}]}], "]"}]}], ";",
       "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"(*", 
       RowBox[{
       "Find", " ", "the", " ", "position", " ", "of", " ", "the", " ", 
        "mutant"}], "*)"}], 
      RowBox[{"posmutant", "=", 
       RowBox[{
        RowBox[{"Flatten", "[", 
         RowBox[{"Position", "[", 
          RowBox[{
           RowBox[{"ansMutated", "[", 
            RowBox[{"[", 
             RowBox[{"1", ",", "3", ",", "All", ",", "2"}], "]"}], "]"}], ",", 
           RowBox[{
            RowBox[{"(", 
             RowBox[{"First", "/@", "duplicates"}], ")"}], "[", 
            RowBox[{"[", "1", "]"}], "]"}]}], "]"}], "]"}], "[", 
        RowBox[{"[", "2", "]"}], "]"}]}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"(*", 
       RowBox[{
       "Create", " ", "the", " ", "combined", " ", "population", " ", "of", 
        " ", "mutants"}], "*)"}], 
      RowBox[{"combinedpopmutant", "=", 
       RowBox[{"Join", "[", 
        RowBox[{
         RowBox[{"Table", "[", 
          RowBox[{"0", ",", 
           RowBox[{"{", 
            RowBox[{"i", ",", "1", ",", "mutationtime"}], "}"}]}], "]"}], ",", 
         RowBox[{
          RowBox[{"ansMutated", "[", 
           RowBox[{"[", 
            RowBox[{"All", ",", "1", ",", "posmutant"}], "]"}], "]"}], "[", 
          RowBox[{"[", 
           RowBox[{"All", ",", "2"}], "]"}], "]"}]}], "]"}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"combinedPopMutant", "=", 
       RowBox[{"Table", "[", 
        RowBox[{
         RowBox[{
          SubscriptBox["Ni", 
           RowBox[{"posmutant", ",", "t"}]], "->", 
          RowBox[{"combinedpopmutant", "[", 
           RowBox[{"[", 
            RowBox[{"t", "+", "1"}], "]"}], "]"}]}], ",", 
         RowBox[{"{", 
          RowBox[{"t", ",", "0", ",", 
           RowBox[{
            RowBox[{"Length", "[", "combinedpopmutant", "]"}], "-", "1"}]}], 
          "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"(*", 
       RowBox[{"Create", " ", "the", " ", "combined", " ", "population"}], 
       "*)"}], "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"combinedPop", "=", 
       RowBox[{"Join", "[", 
        RowBox[{
         RowBox[{
          RowBox[{"Total", "[", 
           RowBox[{
            RowBox[{"ans", "[", 
             RowBox[{"[", 
              RowBox[{"All", ",", "1", ",", "All", ",", "2"}], "]"}], "]"}], 
            ",", 
            RowBox[{"{", "2", "}"}]}], "]"}], "[", 
          RowBox[{"[", 
           RowBox[{"1", ";;", "mutationtime"}], "]"}], "]"}], ",", 
         RowBox[{"Total", "[", 
          RowBox[{
           RowBox[{"ansMutated", "[", 
            RowBox[{"[", 
             RowBox[{"All", ",", "1", ",", "All", ",", "2"}], "]"}], "]"}], 
           ",", 
           RowBox[{"{", "2", "}"}]}], "]"}]}], "]"}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"combinedPop", "=", 
       RowBox[{"Table", "[", 
        RowBox[{
         RowBox[{
          SubscriptBox["N", "t"], "->", 
          RowBox[{"combinedPop", "[", 
           RowBox[{"[", 
            RowBox[{"t", "+", "1"}], "]"}], "]"}]}], ",", 
         RowBox[{"{", 
          RowBox[{"t", ",", "0", ",", 
           RowBox[{
            RowBox[{"Length", "[", "combinedPop", "]"}], "-", "1"}]}], 
          "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"(*", 
       RowBox[{"Return", " ", "desired", " ", "results"}], "*)"}], 
      "\[IndentingNewLine]", 
      RowBox[{"{", 
       RowBox[{"combinedR", ",", "combinedPopMutant", ",", "combinedPop"}], 
       "}"}]}]}], "]"}]}], "\n"}]], "Input",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.},
 CellChangeTimes->{{3.9009926112611303`*^9, 3.900992662895574*^9}, {
   3.90099279244693*^9, 3.900992820355926*^9}, {3.900992919928892*^9, 
   3.900992922945775*^9}, 3.9009929926736917`*^9, 3.902827371380163*^9},
 CellLabel->"In[82]:=",ExpressionUUID->"c495fdbe-7294-427f-ad50-844a3e47814c"]
}, Closed]]
},
WindowSize->{1455, 639},
WindowMargins->{{0, Automatic}, {Automatic, 19}},
FrontEndVersion->"13.2 for Mac OS X ARM (64-bit) (January 30, 2023)",
StyleDefinitions->"Default.nb",
ExpressionUUID->"f777772f-9022-45cd-9273-ff827a2c9659"
]
(* End of Notebook Content *)

(* Internal cache information *)
(*CellTagsOutline
CellTagsIndex->{}
*)
(*CellTagsIndex
CellTagsIndex->{}
*)
(*NotebookFileOutline
Notebook[{
Cell[558, 20, 1967, 65, 94, "Input",ExpressionUUID->"f343e170-cce4-48b2-ab42-d6f7c113e011"],
Cell[CellGroupData[{
Cell[2550, 89, 3223, 60, 94, "Input",ExpressionUUID->"471ccfe1-307a-4ca5-8202-83acdbfd43a5",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.}],
Cell[5776, 151, 90575, 1904, 6028, "Input",ExpressionUUID->"94dee60f-bc42-4a1e-8b17-64de82078d28",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.}]
}, Closed]],
Cell[CellGroupData[{
Cell[96388, 2060, 882, 16, 26, "Input",ExpressionUUID->"8fe704a3-0299-40a4-a371-3a95e2d3b8a1",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.}],
Cell[97273, 2078, 6011, 135, 409, "Input",ExpressionUUID->"d2d9e949-5307-4c13-a17c-ca53cf24cbaa",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.}]
}, Closed]],
Cell[CellGroupData[{
Cell[103321, 2218, 1440, 22, 26, "Input",ExpressionUUID->"2283dd61-4aca-4e7c-ae08-eeb7a047b714",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.}],
Cell[104764, 2242, 68022, 1440, 4863, "Input",ExpressionUUID->"f7b7db0c-e37c-4f4b-a5ba-b83ff4e8eedf",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.}]
}, Closed]],
Cell[CellGroupData[{
Cell[172823, 3687, 446, 8, 26, "Input",ExpressionUUID->"137a0b85-9312-4bcd-987f-05e5f57e678e",
 CellGroupingRules->{"GroupTogetherGrouping", 10002.}],
Cell[173272, 3697, 5656, 134, 573, "Input",ExpressionUUID->"ce49bceb-045f-4747-a724-9152dae73fb7",
 CellGroupingRules->{"GroupTogetherGrouping", 10002.}]
}, Closed]],
Cell[CellGroupData[{
Cell[178965, 3836, 3544, 69, 174, "Input",ExpressionUUID->"cfc7c8c1-2083-4ad0-b0f1-94dabb04af60",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.}],
Cell[182512, 3907, 8379, 198, 705, "Input",ExpressionUUID->"a4178c52-68c2-4978-aa44-331136a1f4ed",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.}]
}, Closed]],
Cell[CellGroupData[{
Cell[190928, 4110, 536, 10, 26, "Input",ExpressionUUID->"229dfa80-6c2b-4c86-9bd2-a460ae6843b6",
 CellGroupingRules->{"GroupTogetherGrouping", 10002.}],
Cell[191467, 4122, 15613, 371, 739, "Input",ExpressionUUID->"2228675a-62d9-4d58-8f8d-0cae9ab0fc1e",
 CellGroupingRules->{"GroupTogetherGrouping", 10002.}]
}, Closed]],
Cell[CellGroupData[{
Cell[207117, 4498, 753, 13, 26, "Input",ExpressionUUID->"06eacbd9-2999-4625-9d78-d8e28af7cf93",
 CellGroupingRules->{"GroupTogetherGrouping", 10004.}],
Cell[207873, 4513, 11784, 279, 747, "Input",ExpressionUUID->"3d5ea2ce-3745-4601-affd-ffbe66dfc57c",
 CellGroupingRules->{"GroupTogetherGrouping", 10004.}]
}, Closed]],
Cell[CellGroupData[{
Cell[219694, 4797, 768, 14, 48, "Input",ExpressionUUID->"010898c2-81bd-4540-b2db-cdbe621ef814",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.}],
Cell[220465, 4813, 16053, 362, 1606, "Input",ExpressionUUID->"14e88dc4-3e24-47b4-baf1-ff642985e626",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.}]
}, Closed]],
Cell[CellGroupData[{
Cell[236555, 5180, 602, 12, 26, "Input",ExpressionUUID->"ff851ad5-70ed-4bb3-b111-07609c9c3808",
 CellGroupingRules->{"GroupTogetherGrouping", 10003.}],
Cell[237160, 5194, 5486, 110, 634, "Input",ExpressionUUID->"1ca0154b-43da-46c6-a7e4-599e81af62e8",
 CellGroupingRules->{"GroupTogetherGrouping", 10003.}]
}, Closed]],
Cell[CellGroupData[{
Cell[242683, 5309, 588, 11, 26, "Input",ExpressionUUID->"7fa14643-0c6a-4567-ae31-85379b2e62eb",
 CellGroupingRules->{"GroupTogetherGrouping", 10002.}],
Cell[243274, 5322, 7261, 168, 619, "Input",ExpressionUUID->"de110204-d22e-4104-951b-996735b9f8e2",
 CellGroupingRules->{"GroupTogetherGrouping", 10002.}]
}, Closed]],
Cell[CellGroupData[{
Cell[250572, 5495, 564, 11, 26, "Input",ExpressionUUID->"3ecef7cf-5e31-4253-b90c-bb19558da7d5",
 CellGroupingRules->{"GroupTogetherGrouping", 10003.}],
Cell[251139, 5508, 6490, 150, 478, "Input",ExpressionUUID->"1f23d4ed-3961-499b-8060-9a58d7b39ad6",
 CellGroupingRules->{"GroupTogetherGrouping", 10003.}]
}, Closed]],
Cell[CellGroupData[{
Cell[257666, 5663, 469, 9, 26, "Input",ExpressionUUID->"41f72e75-c163-48ee-89be-74d9ec6c244a",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.}],
Cell[258138, 5674, 1270, 24, 73, "Input",ExpressionUUID->"001d8964-bdf3-45d3-95e7-a7f4d1b66ef8",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.}],
Cell[259411, 5700, 4004, 92, 320, "Input",ExpressionUUID->"6920635c-271c-4673-a1fa-95380b89c0f9",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.}]
}, Closed]],
Cell[CellGroupData[{
Cell[263452, 5797, 803, 15, 48, "Input",ExpressionUUID->"8285b187-fce7-40cf-93e1-1cbaa42b7161",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.}],
Cell[264258, 5814, 4220, 111, 220, "Input",ExpressionUUID->"843acaaa-a990-48ee-99d5-48cd91aa6919",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.}],
Cell[268481, 5927, 2322, 43, 458, "CodeText",ExpressionUUID->"62ef0130-7b9a-4023-b534-4aa698d0a8c9",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.}]
}, Closed]],
Cell[CellGroupData[{
Cell[270840, 5975, 638, 10, 69, "Input",ExpressionUUID->"b970fc46-3af7-4ca6-b306-a38620a56cba",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.}],
Cell[271481, 5987, 10231, 225, 955, "Input",ExpressionUUID->"4028668f-5ca7-49c4-b7c2-50b6e30307c6",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.}]
}, Closed]],
Cell[CellGroupData[{
Cell[281749, 6217, 658, 10, 48, "Input",ExpressionUUID->"04c1184a-4e5b-4819-87f6-aa4320f22543",
 CellGroupingRules->{"GroupTogetherGrouping", 10002.}],
Cell[282410, 6229, 6921, 134, 829, "Input",ExpressionUUID->"35309c83-b686-4210-91d8-44951d75966a",
 CellGroupingRules->{"GroupTogetherGrouping", 10002.}]
}, Closed]],
Cell[CellGroupData[{
Cell[289368, 6368, 431, 10, 26, "Input",ExpressionUUID->"d4d56de5-aea6-4664-8f05-d7094dca4bbf",
 CellGroupingRules->{"GroupTogetherGrouping", 10003.}],
Cell[289802, 6380, 629, 16, 30, "Input",ExpressionUUID->"9823bb01-8120-48db-b1ee-b75f73ab1bd2",
 CellGroupingRules->{"GroupTogetherGrouping", 10003.}]
}, Closed]],
Cell[CellGroupData[{
Cell[290468, 6401, 479, 10, 26, "Input",ExpressionUUID->"4c6dd1a5-99cd-4b74-bd1c-b502ad6e80f8",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.}],
Cell[290950, 6413, 11849, 284, 704, "Input",ExpressionUUID->"d8f390d8-9205-42d3-9420-ea4a9b6c84c0",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.}]
}, Closed]],
Cell[CellGroupData[{
Cell[302836, 6702, 646, 12, 26, "Input",ExpressionUUID->"1b626701-011b-4c14-9f31-636e5a325f91",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.}],
Cell[303485, 6716, 10703, 274, 1127, "Input",ExpressionUUID->"b2a39932-4785-480a-8701-3c34a4ca851f",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.}]
}, Closed]],
Cell[CellGroupData[{
Cell[314225, 6995, 1318, 24, 69, "Input",ExpressionUUID->"9dd08808-69ae-40dd-a965-6c90fe2be12e",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.}],
Cell[315546, 7021, 19956, 494, 1274, "Input",ExpressionUUID->"ac217197-d25d-44b4-8f87-be34150c2da2",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.}]
}, Closed]],
Cell[CellGroupData[{
Cell[335539, 7520, 1120, 20, 69, "Input",ExpressionUUID->"a87a2642-37cf-4d61-8ed2-2f722873ca84",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.}],
Cell[336662, 7542, 19297, 465, 1496, "Input",ExpressionUUID->"d0e93cd0-b9a4-4575-8aac-c153cbfda9e5",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.}]
}, Closed]],
Cell[355974, 8010, 342, 9, 26, "Input",ExpressionUUID->"b2ce7e60-13ab-456e-8fc0-bc382130a1f1"],
Cell[CellGroupData[{
Cell[356341, 8023, 2612, 46, 73, "Input",ExpressionUUID->"6923173b-7cb8-430a-8c88-dde690549f80",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.}],
Cell[358956, 8071, 1064, 21, 73, "Input",ExpressionUUID->"234a0161-b3f2-484a-8aa6-eb5f8cb806dc",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.}],
Cell[360023, 8094, 91760, 1872, 5736, "Input",ExpressionUUID->"625c85b7-68f4-4271-a435-0b60f8618dde",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.}]
}, Closed]],
Cell[CellGroupData[{
Cell[451820, 9971, 3511, 62, 111, "Input",ExpressionUUID->"a873ae3b-807f-45c9-a6c5-bd83d286f954",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.}],
Cell[455334, 10035, 1086, 21, 73, "Input",ExpressionUUID->"acf46a6d-6b6b-42a1-8ba3-3c56f710484f",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.}],
Cell[456423, 10058, 91596, 1829, 5484, "Input",ExpressionUUID->"0d33c2cf-e40d-40a6-b15a-5d60da41384a",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.}]
}, Closed]],
Cell[CellGroupData[{
Cell[548056, 11892, 703, 15, 26, "Input",ExpressionUUID->"893438a8-9aec-4dd9-9970-69e9a87b4b6e",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.}],
Cell[548762, 11909, 823, 18, 30, "Input",ExpressionUUID->"5653b452-5861-4ca2-8fa8-a5a4e15bd213",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.}]
}, Closed]],
Cell[CellGroupData[{
Cell[549622, 11932, 601, 13, 26, "Input",ExpressionUUID->"9ea4e1ba-0732-4533-a925-e31e16f5b11f",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.}],
Cell[550226, 11947, 3419, 85, 325, "Input",ExpressionUUID->"0313b796-1788-4d29-aa53-77b7c9ab3f56",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.}]
}, Closed]],
Cell[CellGroupData[{
Cell[553682, 12037, 992, 20, 48, "Input",ExpressionUUID->"de67cd4f-4898-4682-9364-758f4e937115",
 CellGroupingRules->{"GroupTogetherGrouping", 10006.}],
Cell[554677, 12059, 2343, 54, 409, "Input",ExpressionUUID->"6609e521-4ae3-4e2b-a36c-3044827a29b8",
 CellGroupingRules->{"GroupTogetherGrouping", 10006.}]
}, Closed]],
Cell[CellGroupData[{
Cell[557057, 12118, 980, 20, 48, "Input",ExpressionUUID->"0ac80e0c-85fc-46c5-b89b-8a7c4caf2cbb",
 CellGroupingRules->{"GroupTogetherGrouping", 10005.}],
Cell[558040, 12140, 4173, 104, 598, "Input",ExpressionUUID->"25f0e9fd-2df7-45cb-8d0c-17335c26b7ed",
 CellGroupingRules->{"GroupTogetherGrouping", 10005.}],
Cell[562216, 12246, 335, 7, 30, "Input",ExpressionUUID->"a161a501-b618-42fc-b252-b0b5d3d66dbb",
 CellGroupingRules->{"GroupTogetherGrouping", 10005.}]
}, Closed]],
Cell[CellGroupData[{
Cell[562588, 12258, 727, 14, 26, "Input",ExpressionUUID->"d3d167fe-d724-4c05-acb0-27e21ebedae6",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.}],
Cell[563318, 12274, 956, 20, 30, "Input",ExpressionUUID->"6e8a8d3e-255e-4c88-a04c-48d545d01f1d",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.}]
}, Closed]],
Cell[CellGroupData[{
Cell[564311, 12299, 839, 15, 48, "Input",ExpressionUUID->"3ed22e86-6983-4e9c-9857-6b75f15f81a2",
 CellGroupingRules->{"GroupTogetherGrouping", 10005.}],
Cell[565153, 12316, 1103, 24, 30, "Input",ExpressionUUID->"abedbc39-d76d-4985-a800-b0b83907abdd",
 CellGroupingRules->{"GroupTogetherGrouping", 10005.}]
}, Closed]],
Cell[CellGroupData[{
Cell[566293, 12345, 2023, 36, 111, "Input",ExpressionUUID->"18f86bc5-2c3b-4620-888e-cef65b809138",
 CellGroupingRules->{"GroupTogetherGrouping", 10004.}],
Cell[568319, 12383, 4791, 107, 556, "Input",ExpressionUUID->"6d20dfc5-7ea8-40b2-98ec-60de1273267d",
 CellGroupingRules->{"GroupTogetherGrouping", 10004.}]
}, Closed]],
Cell[CellGroupData[{
Cell[573147, 12495, 1119, 22, 48, "Input",ExpressionUUID->"fc26ef9d-123d-47e0-8941-9fb13070e900",
 CellGroupingRules->{"GroupTogetherGrouping", 10002.}],
Cell[574269, 12519, 1294, 27, 51, "Input",ExpressionUUID->"d4dc1cd7-599e-4512-8bf8-6e93e8d0a2e6",
 CellGroupingRules->{"GroupTogetherGrouping", 10002.}]
}, Closed]],
Cell[CellGroupData[{
Cell[575600, 12551, 1175, 27, 48, "Input",ExpressionUUID->"2d7e905b-ff5b-4b4c-945e-04fb7e4a62da",
 CellGroupingRules->{"GroupTogetherGrouping", 10003.}],
Cell[576778, 12580, 20669, 434, 1903, "Input",ExpressionUUID->"640ec9fb-161a-4cde-92e4-fe6aa0d8b08d",
 CellGroupingRules->{"GroupTogetherGrouping", 10003.}]
}, Closed]],
Cell[CellGroupData[{
Cell[597484, 13019, 543, 11, 26, "Input",ExpressionUUID->"eef4fad9-3fb1-43db-a229-4a612112b773",
 CellGroupingRules->{"GroupTogetherGrouping", 10004.}],
Cell[598030, 13032, 703, 17, 73, "Input",ExpressionUUID->"a920aebb-9734-4bee-8bde-a425ca5d564c",
 CellGroupingRules->{"GroupTogetherGrouping", 10004.}]
}, Closed]],
Cell[CellGroupData[{
Cell[598770, 13054, 638, 12, 69, "Input",ExpressionUUID->"b37660c9-50e6-4ede-a51d-9e263a95e3aa",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.}],
Cell[599411, 13068, 2758, 50, 220, "Input",ExpressionUUID->"a5f9cfc3-d73e-43d6-b5c6-a7fe9646af6a",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.}],
Cell[602172, 13120, 4688, 111, 430, "Input",ExpressionUUID->"82964368-1f1f-4da4-a224-968e325c4451",
 CellGroupingRules->{"GroupTogetherGrouping", 10000.}]
}, Closed]],
Cell[CellGroupData[{
Cell[606897, 13236, 1364, 28, 90, "Input",ExpressionUUID->"c26e07c8-1fa6-4f94-9856-f9b7d1ec1c48",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.}],
Cell[608264, 13266, 6814, 173, 604, "Input",ExpressionUUID->"c495fdbe-7294-427f-ad50-844a3e47814c",
 CellGroupingRules->{"GroupTogetherGrouping", 10001.}]
}, Closed]]
}
]
*)

